growi-theme-metadata.ts 1.4 KB

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