-
Notifications
You must be signed in to change notification settings - Fork 3
add client facing theme #96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Jipperism
wants to merge
8
commits into
main
Choose a base branch
from
feature/add-client-facing-theme
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
05aa972
split up stories between raidguild and client theme
Jipperism 063ebd7
rewrite all molecule stories to separate themes
Jipperism 3cd2007
switch to using theme switch in top bar
Jipperism f31e688
add storybook theme based utility functions
Jipperism f4babfe
rename for consistency
Jipperism 85b47a6
remove redundant file
Jipperism b47c6e5
refactor naming fix
Jipperism 58ccb9b
update gitignore
Jipperism File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| import { INITIAL_VIEWPORTS } from '@storybook/addon-viewport'; | ||
| import { Fonts, Box, RGThemeProvider, defaultTheme, clientTheme } from '../src'; | ||
| import { Decorator } from '@storybook/react'; | ||
| import React from 'react'; | ||
| import { StoryBookThemeContext } from '../src/stories/utils'; | ||
|
|
||
| export const parameters = { | ||
| viewport: { | ||
| viewports: INITIAL_VIEWPORTS, | ||
| }, | ||
| actions: { argTypesRegex: '^on[A-Z].*' }, | ||
| // Storybook a11y addon configuration | ||
| a11y: { | ||
| // the target DOM element | ||
| element: '#root', | ||
| // sets the execution mode for the addon | ||
| manual: false, | ||
| }, | ||
| controls: { | ||
| expanded: true, | ||
| matchers: { | ||
| color: /(background|color)$/i, | ||
| date: /Date$/, | ||
| }, | ||
| }, | ||
| options: { | ||
| storySort: { | ||
| method: 'alphabetical', | ||
| }, | ||
| }, | ||
| }; | ||
|
|
||
| export const globalTypes = { | ||
| theme: { | ||
| name: 'Theme', | ||
| description: 'Global theme for components', | ||
| defaultValue: 'light', | ||
| toolbar: { | ||
| icon: 'circlehollow', | ||
| // Array of plain string values or MenuItem shape (see below) | ||
| items: ['guild', 'client'], | ||
| // Property that specifies if the name of the item will be displayed | ||
| showName: true, | ||
| // Change title based on selected value | ||
| dynamicTitle: true, | ||
| }, | ||
| }, | ||
| }; | ||
|
|
||
| export const decorators: Decorator[] = [ | ||
| (Story, context) => { | ||
| const theme = context.parameters.theme || context.globals.theme; | ||
| const storyTheme = theme === 'guild' ? defaultTheme : clientTheme; | ||
| return ( | ||
| <Box> | ||
| <Fonts /> | ||
| <StoryBookThemeContext.Provider value={{ theme }}> | ||
| <RGThemeProvider theme={storyTheme}> | ||
| <Story /> | ||
| </RGThemeProvider> | ||
| </StoryBookThemeContext.Provider> | ||
| </Box> | ||
| ); | ||
| }, | ||
| ]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| export { default as RoleBadge } from './RoleBadge'; | ||
| export { default as RoleBadge, RoleBadgeProps } from './RoleBadge'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| import { Meta } from '@storybook/react'; | ||
| import type { StoryFn } from '@storybook/react'; | ||
| import React from 'react'; | ||
|
|
||
| import { Heading, Stack, Text, Flex, Box } from '..'; | ||
|
|
||
| import castle from '../assets/images/raid-guild-castle.png'; | ||
| import FooterSimple from '../components/footers/FooterSimple'; | ||
|
|
||
| export const ClientDesignSystem: StoryFn = () => ( | ||
| <Box position='relative'> | ||
| <Box | ||
| bgImg={castle} | ||
| left={0} | ||
| top={0} | ||
| right={0} | ||
| bottom={0} | ||
| backgroundSize='cover' | ||
| backgroundPosition='right' | ||
| backgroundRepeat='no-repeat' | ||
| opacity={0.4} | ||
| position='absolute' | ||
| zIndex={-1} | ||
| /> | ||
| <Flex direction='column' justify='space-between' minH='70vh' w='100%'> | ||
| <Stack align='center' spacing={6} my={40}> | ||
| <Heading as='h1' size='3xl' color='white' textAlign='center'> | ||
| Raid Guild Design Guide | ||
| </Heading> | ||
| <Text align='center' mb={5} fontFamily='texturina'> | ||
| Use the navigation on the left to explore existing components built | ||
| with Raid Guild styling. | ||
| </Text> | ||
| </Stack> | ||
| <FooterSimple /> | ||
| </Flex> | ||
| </Box> | ||
| ); | ||
|
|
||
| export default { | ||
| title: 'Client Design System', | ||
| component: ClientDesignSystem, | ||
| parameters: { | ||
| chakra: { | ||
| theme: {}, | ||
| }, | ||
| }, | ||
| } as Meta; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| /* eslint-disable react/jsx-no-useless-fragment */ | ||
| import React, { PropsWithChildren, useContext } from 'react'; | ||
|
|
||
| export const StoryBookThemeContext = React.createContext<{ | ||
| theme: 'client' | 'guild'; | ||
| }>({ theme: 'guild' }); | ||
|
|
||
| export const useCurrentTheme = () => { | ||
| const { theme } = useContext(StoryBookThemeContext); | ||
| return theme; | ||
| }; | ||
|
|
||
| export const RaidGuildThemeOnly = ({ children }: PropsWithChildren) => { | ||
| const theme = useCurrentTheme(); | ||
|
|
||
| if (theme !== 'guild') { | ||
| return null; | ||
| } | ||
|
|
||
| return <>{children}</>; | ||
| }; | ||
|
|
||
| export const ClientThemeOnly = ({ children }: PropsWithChildren) => { | ||
| const theme = useCurrentTheme(); | ||
|
|
||
| if (theme !== 'client') { | ||
| return null; | ||
| } | ||
|
|
||
| return <>{children}</>; | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.