-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Storybook: Add theme switcher tool (#44715)
* Storybook: Add theme switcher * Add comments
- Loading branch information
Showing
2 changed files
with
48 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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,28 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import Theme from '../../packages/components/src/theme'; | ||
|
||
/** | ||
* A Storybook decorator to show a div before and after the story to check for unwanted margins. | ||
*/ | ||
|
||
export const WithTheme = ( Story, context ) => { | ||
const themes = { | ||
default: {}, | ||
modern: { | ||
accent: '#3858e9', | ||
}, | ||
sunrise: { | ||
// This color was chosen intentionally, because for sufficient contrast, | ||
// the foreground text should be black when this orange is used as a background color. | ||
accent: '#dd823b', | ||
}, | ||
}; | ||
|
||
return ( | ||
<Theme { ...themes[ context.globals.componentsTheme ] }> | ||
<Story { ...context } /> | ||
</Theme> | ||
); | ||
}; |
This file contains 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