growi-theme-metadata.ts 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import { ColorScheme } from './color-scheme';
  2. export const GrowiThemeSchemeType = {
  3. ...ColorScheme,
  4. BOTH: 'both',
  5. } as const;
  6. export type GrowiThemeSchemeType =
  7. (typeof GrowiThemeSchemeType)[keyof typeof GrowiThemeSchemeType];
  8. export type GrowiThemeMetadata = {
  9. name: string;
  10. manifestKey: string;
  11. schemeType: GrowiThemeSchemeType;
  12. lightBg: string;
  13. darkBg: string;
  14. lightSidebar: string;
  15. darkSidebar: string;
  16. lightIcon: string;
  17. darkIcon: string;
  18. createBtn: string;
  19. isPresetTheme?: boolean;
  20. };
  21. export const isGrowiThemeMetadata = (
  22. obj: unknown,
  23. ): obj is GrowiThemeMetadata => {
  24. // biome-ignore lint/suspicious/noExplicitAny: ignore
  25. const objAny = obj as any;
  26. return (
  27. objAny != null &&
  28. typeof objAny === 'object' &&
  29. Array.isArray(objAny) === false &&
  30. 'name' in objAny &&
  31. typeof objAny.name === 'string' &&
  32. 'manifestKey' in objAny &&
  33. typeof objAny.manifestKey === 'string' &&
  34. 'schemeType' in objAny &&
  35. typeof objAny.schemeType === 'string' &&
  36. 'lightBg' in objAny &&
  37. typeof objAny.lightBg === 'string' &&
  38. 'darkBg' in objAny &&
  39. typeof objAny.darkBg === 'string' &&
  40. 'lightSidebar' in objAny &&
  41. typeof objAny.lightSidebar === 'string' &&
  42. 'darkSidebar' in objAny &&
  43. typeof objAny.darkSidebar === 'string' &&
  44. 'lightIcon' in objAny &&
  45. typeof objAny.lightIcon === 'string' &&
  46. 'darkIcon' in objAny &&
  47. typeof objAny.darkIcon === 'string' &&
  48. 'createBtn' in objAny &&
  49. typeof objAny.createBtn === 'string'
  50. );
  51. };