diff --git a/.changeset/large-games-impress.md b/.changeset/large-games-impress.md new file mode 100644 index 00000000..4544d6c8 --- /dev/null +++ b/.changeset/large-games-impress.md @@ -0,0 +1,5 @@ +--- +'@supabase/auth-ui-react': minor +--- + +Themes now need to be imported and used as a prop in the `` component diff --git a/packages/react/common/theming/defaultThemes.ts b/packages/react/common/theming/defaultThemes.ts new file mode 100644 index 00000000..a9ef3786 --- /dev/null +++ b/packages/react/common/theming/defaultThemes.ts @@ -0,0 +1,155 @@ +/** + * Create default theme + * + * createStitches() + * https://stitches.dev/docs/api#theme + * + * to add a new theme use createTheme({}) + * https://stitches.dev/docs/api#theme + */ + +import { Theme } from './../../src/types' + +// brand: 'hsl(252 62% 55%)', +// brandAccent: 'hsl(252 62% 45%)', + +export const Supa: Theme = { + default: { + colors: { + brand: 'hsl(153 60.0% 53.0%)', + brandAccent: 'hsl(154 54.8% 45.1%)', + brandButtonText: 'white', + defaultButtonBackground: 'white', + defaultButtonBackgroundHover: '#eaeaea', + defaultButtonBorder: 'lightgray', + defaultButtonText: 'gray', + dividerBackground: '#eaeaea', + inputBackground: 'transparent', + inputBorder: 'lightgray', + inputBorderHover: 'gray', + inputBorderFocus: 'gray', + inputText: 'black', + inputLabelText: 'gray', + inputPlaceholder: 'darkgray', + messageText: 'gray', + messageTextDanger: 'red', + anchorTextColor: 'gray', + anchorTextHoverColor: 'darkgray', + }, + space: { + spaceSmall: '4px', + spaceMedium: '8px', + spaceLarge: '16px', + labelBottomMargin: '8px', + anchorBottomMargin: '4px', + emailInputSpacing: '4px', + socialAuthSpacing: '4px', + buttonPadding: '10px 15px', + inputPadding: '10px 15px', + }, + fontSizes: { + baseBodySize: '13px', + baseInputSize: '14px', + baseLabelSize: '14px', + baseButtonSize: '14px', + }, + fonts: { + bodyFontFamily: `ui-sans-serif, sans-serif`, + buttonFontFamily: `ui-sans-serif, sans-serif`, + inputFontFamily: `ui-sans-serif, sans-serif`, + labelFontFamily: `ui-sans-serif, sans-serif`, + }, + // fontWeights: {}, + // lineHeights: {}, + // letterSpacings: {}, + // sizes: {}, + borderWidths: { + buttonBorderWidth: '1px', + inputBorderWidth: '1px', + }, + // borderStyles: {}, + radii: { + borderRadiusButton: '4px', + buttonBorderRadius: '4px', + inputBorderRadius: '4px', + }, + // shadows: {}, + // zIndices: {}, + // transitions: {}, + }, + dark: { + colors: { + brandButtonText: 'white', + defaultButtonBackground: '#2e2e2e', + defaultButtonBackgroundHover: '#3e3e3e', + defaultButtonBorder: '#3e3e3e', + defaultButtonText: 'white', + dividerBackground: '#2e2e2e', + inputBackground: '#1e1e1e', + inputBorder: '#3e3e3e', + inputBorderHover: 'gray', + inputBorderFocus: 'gray', + inputText: 'white', + inputPlaceholder: 'darkgray', + }, + }, +} + +export const Minimal: Theme = { + default: { + colors: { + brand: 'black', + brandAccent: '#333333', + brandButtonText: 'white', + defaultButtonBackground: 'white', + defaultButtonBorder: 'lightgray', + defaultButtonText: 'gray', + dividerBackground: '#eaeaea', + inputBackground: 'transparent', + inputBorder: 'lightgray', + inputText: 'black', + inputPlaceholder: 'darkgray', + }, + space: { + spaceSmall: '4px', + spaceMedium: '8px', + spaceLarge: '16px', + }, + fontSizes: { + baseInputSize: '14px', + baseLabelSize: '12px', + }, + fonts: { + bodyFontFamily: '', + inputFontFamily: '', + buttonFontFamily: '', + labelFontFamily: '', + // linkFontFamily: '', + }, + // fontWeights: {}, + // lineHeights: {}, + // letterSpacings: {}, + // sizes: {}, + borderWidths: {}, + // borderStyles: {}, + radii: {}, + // shadows: {}, + // zIndices: {}, + // transitions: {}, + }, + dark: { + colors: { + brand: 'white', + brandAccent: '#afafaf', + brandButtonText: 'black', + defaultButtonBackground: '#080808', + defaultButtonBorder: 'black', + defaultButtonText: 'white', + dividerBackground: 'black', + inputBackground: 'transparent', + inputBorder: 'gray', + inputText: 'black', + inputPlaceholder: 'darkgray', + }, + }, +} diff --git a/packages/react/src/components/Auth/Appearance.stories.tsx b/packages/react/src/components/Auth/Appearance.stories.tsx index 3a98558e..7534581b 100644 --- a/packages/react/src/components/Auth/Appearance.stories.tsx +++ b/packages/react/src/components/Auth/Appearance.stories.tsx @@ -3,6 +3,7 @@ import { createClient } from '@supabase/supabase-js' import { useDarkMode } from 'storybook-dark-mode' import { Auth } from '.' import { Button, Message } from '../UI' +import { Supa } from './../../../common/theming/defaultThemes' const supabase = createClient( 'https://rsnibhkhsbfnncjmwnkj.supabase.co', @@ -35,14 +36,14 @@ export const Default = (args: any) => { { + // // return + // }) + + const [authView, setAuthView] = useState(view) + const [defaultEmail, setDefaultEmail] = useState('') + const [defaultPassword, setDefaultPassword] = useState('') + + /** + * Simple boolean to detect if authView 'sign_in' or 'sign_up' is used + * + * @returns boolean + */ + const SignView = authView === 'sign_in' || authView === 'sign_up' + /** * Create default theme * @@ -82,32 +95,11 @@ function Auth({ */ createStitches({ theme: merge( - themes[appearance.theme ?? 'supabase'], - appearance.variables?.light ?? {} + appearance?.theme?.default, + appearance?.variables?.default ?? {} ), }) - /** - * merge theme variables with for dark theme - */ - const darkTheme = createTheme( - merge( - themes.darkThemes[appearance.theme ?? 'supabase'], - appearance.variables?.dark ?? {} - ) - ) - - const [authView, setAuthView] = useState(view) - const [defaultEmail, setDefaultEmail] = useState('') - const [defaultPassword, setDefaultPassword] = useState('') - - /** - * Simple boolean to detect if authView 'sign_in' or 'sign_up' is used - * - * @returns boolean - */ - const SignView = authView === 'sign_in' || authView === 'sign_up' - /** * Wraps around all auth components * renders the social auth providers if SignView is true @@ -118,7 +110,19 @@ function Auth({ * @returns React.ReactNode */ const Container = ({ children }: { children: React.ReactNode }) => ( -
+
{SignView && (