diff --git a/src/components/AppLoading.tsx b/src/components/AppLoading.tsx index 33526997..17ea7c8e 100644 --- a/src/components/AppLoading.tsx +++ b/src/components/AppLoading.tsx @@ -1,17 +1,15 @@ -import { Loader, Center } from '@baca/design-system/components' -import { useCachedResources, useNavigationTheme } from '@baca/hooks' +import { Loader, Center, Box } from '@baca/design-system/components' +import { useCachedResources } from '@baca/hooks' import { useCheckForAppUpdate } from '@baca/hooks/useCheckForAppUpdate' import { isSignedInAtom } from '@baca/store/auth' import * as SplashScreen from 'expo-splash-screen' import { useAtomValue } from 'jotai' import { FC, PropsWithChildren, useCallback, useEffect, useState } from 'react' -import { View, StyleSheet } from 'react-native' // Keep the splash screen visible while we fetch resources SplashScreen.preventAutoHideAsync() export const AppLoading: FC = ({ children }) => { - const { navigationTheme } = useNavigationTheme() const isLoadingComplete = useCachedResources() const isSignedIn = useAtomValue(isSignedInAtom) @@ -38,10 +36,7 @@ export const AppLoading: FC = ({ children }) => { }, [isLoading]) return ( - + {!isSplashHidden ? (
@@ -49,12 +44,6 @@ export const AppLoading: FC = ({ children }) => { ) : ( children )} - + ) } - -const styles = StyleSheet.create({ - container: { - flex: 1, - }, -}) diff --git a/src/components/CompanyLogo.tsx b/src/components/CompanyLogo.tsx index 99ffbc52..84a81079 100644 --- a/src/components/CompanyLogo.tsx +++ b/src/components/CompanyLogo.tsx @@ -1,6 +1,8 @@ import { darkBinarLogo, darkLogoSygnet, lightBinarLogo, lightLogoSygnet } from '@baca/constants' import { ColorSchemeName, useColorScheme } from '@baca/contexts' import { Image, ImageStyle, ImageProps } from 'expo-image' +import { Link } from 'expo-router' +import { Platform, StyleSheet } from 'react-native' type LogoTypes = 'binarSygnet' | 'binar' @@ -16,15 +18,43 @@ export const CompanyLogo = ({ type = 'binar', width = '100%', style, + asImage = false, }: { height?: ImageStyle['height'] type?: LogoTypes width?: ImageStyle['width'] style?: ImageStyle + asImage?: boolean }) => { const { colorScheme } = useColorScheme() const source = LOGO[colorScheme][type] - return + if (Platform.OS !== 'web' || asImage) { + return + } + + return ( + + + + ) } + +const styles = StyleSheet.create({ + image: { + alignItems: 'center', + display: 'flex', + // flex: 1, + justifyContent: 'center', + }, +}) diff --git a/src/components/ThemeSwitcherButton.tsx b/src/components/ThemeSwitcherButton.tsx new file mode 100644 index 00000000..6cf9d6d2 --- /dev/null +++ b/src/components/ThemeSwitcherButton.tsx @@ -0,0 +1,42 @@ +import { useColorScheme } from '@baca/contexts' +import { Icon } from '@baca/design-system' +import { useTheme } from '@baca/hooks' +import { MotiPressable } from 'moti/interactions' +import { useCallback } from 'react' +import { StyleSheet } from 'react-native' + +export const ThemeSwitcherButton = () => { + const { setColorSchemeSetting, colorSchemeSetting } = useColorScheme() + const { colors } = useTheme() + + const handleColorSchemeSettingChange = useCallback(() => { + const scheme = colorSchemeSetting === 'light' ? 'dark' : 'light' + setColorSchemeSetting(scheme) + }, [colorSchemeSetting, setColorSchemeSetting]) + + const icon = colorSchemeSetting === 'light' ? 'moon-line' : 'sun-line' + + return ( + { + 'worklet' + + return { + scale: hovered ? 1.1 : 1, + backgroundColor: hovered ? colors.bg.tertiary : 'transparent', + } + }} + > + + + ) +} + +const styles = StyleSheet.create({ + iconContainter: { + borderRadius: 8, + padding: 8, + }, +}) diff --git a/src/components/molecules/Field/RadioGroup.tsx b/src/components/molecules/Field/RadioGroup.tsx index 5c6615c3..551e623b 100644 --- a/src/components/molecules/Field/RadioGroup.tsx +++ b/src/components/molecules/Field/RadioGroup.tsx @@ -43,3 +43,5 @@ export const RadioGroup = ({ ) } + +RadioGroup.displayName = 'RadioGroup' diff --git a/src/components/molecules/SocialButtons/SocialButton.tsx b/src/components/molecules/SocialButtons/SocialButton.tsx index 25715f71..8e43aeb3 100644 --- a/src/components/molecules/SocialButtons/SocialButton.tsx +++ b/src/components/molecules/SocialButtons/SocialButton.tsx @@ -75,3 +75,5 @@ export const SocialButton: FC = ({ type = 'google', ...rest } ) } + +SocialButton.displayName = 'SocialButton' diff --git a/src/design-system/components/Box.tsx b/src/design-system/components/Box.tsx index a66fb2c6..538f96ff 100644 --- a/src/design-system/components/Box.tsx +++ b/src/design-system/components/Box.tsx @@ -7,3 +7,5 @@ import { generateStyledComponent } from '../utils/generateStyledComponent' export type BoxProps = StyledProps & ViewProps export const Box = memo(generateStyledComponent(View)) + +Box.displayName = 'Box' diff --git a/src/design-system/components/BubblesLoader.tsx b/src/design-system/components/BubblesLoader.tsx index e9ba85a6..bdc76493 100644 --- a/src/design-system/components/BubblesLoader.tsx +++ b/src/design-system/components/BubblesLoader.tsx @@ -1,3 +1,4 @@ +import { useTheme } from '@baca/hooks' import { useBubblesLoader } from '@baca/hooks/loaders' import React from 'react' import Animated from 'react-native-reanimated' @@ -9,12 +10,15 @@ export type BubblesLoaderType = { size?: number } -const FullCircle = ({ size = 10, color = 'black' }: BubblesLoaderType): JSX.Element => ( +const FullCircle = ({ size = 10, color }: BubblesLoaderType): JSX.Element => ( ) -export const BubblesLoader = ({ size = 40, color = 'black' }: BubblesLoaderType): JSX.Element => { +export const BubblesLoader = ({ size = 40, color }: BubblesLoaderType): JSX.Element => { const { animatedHeight, animatedRotate, animatedWidth } = useBubblesLoader() + const theme = useTheme() + + const loaderColor = color || theme.colors.text.primary const containerStyle = { width: size, @@ -37,12 +41,12 @@ export const BubblesLoader = ({ size = 40, color = 'black' }: BubblesLoaderType) return ( - - + + - - + + ) diff --git a/src/design-system/components/Button/Button.tsx b/src/design-system/components/Button/Button.tsx index ab5b7451..34cce16a 100644 --- a/src/design-system/components/Button/Button.tsx +++ b/src/design-system/components/Button/Button.tsx @@ -329,19 +329,42 @@ const Button = generateStyledComponent( RawButton ) as ButtonComposition +Button.displayName = 'Button' + const generateButtonVariant = (variant: ButtonVariant) => forwardRef((props, ref) => - - - + + } + /> + + + } + /> + + } + /> + + } + /> + + } + /> + + + } + /> + + } + /> + + + } + /> + + } + /> + + } + /> + + } + /> + + } + /> + {t('components_screen.button_variants.disabled')} + } + /> + } + /> + + } + /> + } + /> + } + /> + - - - - - + + + + UI Examples + + + + + Navigation + - - - {/* TODO: Add translations */} - - + ) } diff --git a/src/screens/LandingScreen.tsx b/src/screens/LandingScreen.tsx index 52f5b661..4b60c723 100644 --- a/src/screens/LandingScreen.tsx +++ b/src/screens/LandingScreen.tsx @@ -45,7 +45,7 @@ export const LandingScreen = () => { }, [screenWidth]) const renderItem = (item: ImageSourcePropType, index: number) => ( - + @@ -59,7 +59,7 @@ export const LandingScreen = () => { return ( -
+
{t('home_screen.header_title')} diff --git a/src/screens/TypographyScreen.tsx b/src/screens/TypographyScreen.tsx index cfa686db..aa9a66f2 100644 --- a/src/screens/TypographyScreen.tsx +++ b/src/screens/TypographyScreen.tsx @@ -1,9 +1,36 @@ -import { useColorScheme } from '@baca/contexts' -import { Column, Row, Box, Text, Display, DisplayVariant, TextVariant } from '@baca/design-system' +import { + Box, + Text, + Display, + DisplayVariant, + TextVariant, + RenderComponentWithExample, + ScrollView, +} from '@baca/design-system' import { useTranslation } from '@baca/hooks' -import { ScrollView, Switch, Platform } from 'react-native' -export const textVariants: TextVariant[] = [ +const generateTextVariantsToRender = (variants: T, component: React.FC) => { + const originalVariants = Object.keys(component).filter( + (key) => key !== '$$typeof' && key !== 'render' + ) + + // Step 1: Extract elements from array1 that are also in array2 + const commonElements = variants.filter((element) => originalVariants.includes(element)) + + // Step 2: Extract elements from array2 that are not in array1 + const remainingElements = originalVariants.filter((element) => !variants.includes(element)) + + // Step 3: Combine both parts to form the third array + const combinedArray = [...commonElements, ...remainingElements] + + return combinedArray as T +} + +export const textVariantsStrings: TextVariant[] = [ + 'XxlBold', + 'XxlMedium', + 'XxlRegular', + 'XxlSemibold', 'XlBold', 'XlSemibold', 'XlMedium', @@ -26,7 +53,7 @@ export const textVariants: TextVariant[] = [ 'XsRegular', ] as const -const displayTextVariants: DisplayVariant[] = [ +const displayTextVariantsStrings: DisplayVariant[] = [ 'XxlBold', 'XxlSemibold', 'XxlMedium', @@ -52,56 +79,44 @@ const displayTextVariants: DisplayVariant[] = [ 'XsMedium', 'XsRegular', ] as const -const isWeb = Platform.OS === 'web' + +const textVariants = generateTextVariantsToRender(textVariantsStrings, Text) +const displayTextVariants = generateTextVariantsToRender(displayTextVariantsStrings, Display) export const TypographyScreen = (): JSX.Element => { const { t } = useTranslation() - const { setColorSchemeSetting, colorScheme } = useColorScheme() return ( - - - - - 🌞 - {/* - Investigate the issue about using `useCallback` on `onChange` - https://github.com/adobe/react-spectrum/issues/2320 - */} - - - setColorSchemeSetting(colorScheme === 'dark' ? 'light' : 'dark'), - } - : { - onChange: () => - setColorSchemeSetting(colorScheme === 'dark' ? 'light' : 'dark'), - })} - /> - - 🌚 - - - {t('typography_screen.display_font_size')} - - {displayTextVariants.map((variant) => ( - - Display - {variant} - - ))} - - {t('typography_screen.text_font_size')} - - {textVariants.map((variant) => ( - - Text - {variant} - - ))} - - + + + + {t('typography_screen.display_font_size')} + + {displayTextVariants.map((variant) => ( + + {'Display - ' + variant} + + } + /> + ))} + + {t('typography_screen.text_font_size')} + + + {textVariants.map((variant) => ( + {'Text - ' + variant}} + /> + ))} + ) } diff --git a/src/screens/auth/SignInScreen.tsx b/src/screens/auth/SignInScreen.tsx index c81bcb5c..22e253da 100644 --- a/src/screens/auth/SignInScreen.tsx +++ b/src/screens/auth/SignInScreen.tsx @@ -6,6 +6,7 @@ import { SocialButtons, Version, } from '@baca/components' +import { ThemeSwitcherButton } from '@baca/components/ThemeSwitcherButton' import { REGEX, isWeb } from '@baca/constants' import { Box, Button, Center, Display, Row, Spacer, Text } from '@baca/design-system' import { useCallback, useSignInForm, useState, useTranslation } from '@baca/hooks' @@ -31,20 +32,13 @@ export const SignInScreen = (): JSX.Element => { return ( - {isWeb ? ( - - - - - - - ) : null} + + + + + +
- {!isWeb ? ( - - - - ) : null} diff --git a/src/styles/root-layout.module.scss b/src/styles/root-layout.module.scss index 1906f0df..44729550 100644 --- a/src/styles/root-layout.module.scss +++ b/src/styles/root-layout.module.scss @@ -15,6 +15,9 @@ $ui-sidebar: 244px; // Header Logo .headerContainer { padding-top: 0px; + @media (min-width: $size-l) { + padding: 8px; + } } .headerLogo { diff --git a/src/utils/getColorValue.ts b/src/utils/getColorValue.ts index 0771fdf9..8c4f944b 100644 --- a/src/utils/getColorValue.ts +++ b/src/utils/getColorValue.ts @@ -14,7 +14,7 @@ export const getColorValue = ({ color, colors }: GetColorValueProps): string => const colorToReturn = getPropertyByKeys(colors, keys) - return colorToReturn || color + return colorToReturn } interface NestedObject { diff --git a/src/utils/webStyling.ts b/src/utils/webStyling.ts new file mode 100644 index 00000000..8f3860d6 --- /dev/null +++ b/src/utils/webStyling.ts @@ -0,0 +1,16 @@ +import { Platform, StyleProp, ViewStyle } from 'react-native' + +export const makeBigerOnHover = (hovered: boolean): StyleProp => { + return [ + Platform.select({ + web: { + transitionDuration: '200ms', + transitionProperty: ['background-color', 'box-shadow', 'transform'], + transitionTimingFunction: 'cubic-bezier(0.17, 0.17, 0, 1)', + }, + }), + hovered && { + transform: [{ scale: 1.1 }], + }, + ] +}