Files
supabase/studio/components/ui/CodeEditor/CodeEditor.utils.ts
T
9910073432 Chore/proper theme switcher (#17635)
* Add theme switcher

* Update

* Update

* Fix docs

* Update

* Fix www

* Componentize ThemeToggle

* Remove unused TopBarRef, rename existing component

* Update apps/www/pages/launch-week/6/index.tsx

Co-authored-by: Greg Richardson <greg.nmr@gmail.com>

* Update apps/docs/components/Navigation/NavigationMenu/TopNavBar.tsx

Co-authored-by: Greg Richardson <greg.nmr@gmail.com>

* Update apps/www/pages/launch-week/index.tsx

Co-authored-by: Greg Richardson <greg.nmr@gmail.com>

* Update apps/www/pages/launch-week/7/index.tsx

Co-authored-by: Greg Richardson <greg.nmr@gmail.com>

* Update apps/www/pages/launch-week/tickets/[username].tsx

Co-authored-by: Greg Richardson <greg.nmr@gmail.com>

* Update always-on darkmode pages

* update

* Prettier

* Check resolved theme for images

* use resolved theme

* Fix customer stories

* Update apps/docs/components/Navigation/NavigationMenu/TopNavBar.tsx

Co-authored-by: Francesco Sansalvadore <f.sansalvadore@gmail.com>

---------

Co-authored-by: Greg Richardson <greg.nmr@gmail.com>
Co-authored-by: Francesco Sansalvadore <f.sansalvadore@gmail.com>
2023-09-26 16:27:45 +00:00

31 lines
1.0 KiB
TypeScript

export const alignEditor = (editor: any) => {
// Add margin above first line
editor.changeViewZones((accessor: any) => {
accessor.addZone({
afterLineNumber: 0,
heightInPx: 4,
domNode: document.createElement('div'),
})
})
}
export const getTheme = (theme: string) => {
// [TODO] Probably need better theming for light mode
return {
base: theme === 'dark' ? 'vs-dark' : 'vs', // can also be vs-dark or hc-black
inherit: true, // can also be false to completely replace the builtin rules
rules: [
{ background: theme === 'dark' ? '1f1f1f' : 'f0f0f0' },
{
token: '',
background: theme === 'dark' ? '1f1f1f' : 'f0f0f0',
foreground: theme === 'dark' ? 'd4d4d4' : '444444',
},
{ token: 'string.sql', foreground: '24b47e' },
{ token: 'comment', foreground: '666666' },
{ token: 'predefined.sql', foreground: theme === 'dark' ? 'D4D4D4' : '444444' },
],
colors: { 'editor.background': theme === 'dark' ? '#1f1f1f' : '#f0f0f0' },
}
}