-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
reimplement storybook & chromatic (#128)
- Loading branch information
Showing
173 changed files
with
7,998 additions
and
2,895 deletions.
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 @@ | ||
# .github/workflows/chromatic.yml | ||
|
||
# Workflow name | ||
name: 'Chromatic' | ||
|
||
# Event for the workflow | ||
on: push | ||
|
||
# List of jobs | ||
jobs: | ||
chromatic-deployment: | ||
# Operating System | ||
runs-on: ubuntu-latest | ||
# Job steps | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: "0" | ||
- name: Install dependencies | ||
# 👇 Install dependencies with the same package manager used in the project (replace it as needed), e.g. yarn, npm, pnpm | ||
run: yarn | ||
# 👇 Adds Chromatic as a step in the workflow | ||
- name: Publish to Chromatic | ||
uses: chromaui/action@v1 | ||
# Chromatic GitHub Action options | ||
with: | ||
# 👇 Chromatic projectToken, refer to the manage page to obtain it. | ||
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
This file was deleted.
Oops, something went wrong.
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,40 @@ | ||
import React, { useEffect } from 'react'; | ||
|
||
import { action } from '@storybook/addon-actions'; | ||
import { StoryFn } from '@storybook/react'; | ||
|
||
/* | ||
For mocking component button functionality only: | ||
the decorator intercepts and overrides component level button actions instead of trying to execute a mutation | ||
*/ | ||
const withButtonOverrides = (domQuery: string, actionType: string, actionDescription: string) => { | ||
return (StoryFn: StoryFn) => { | ||
useEffect(() => { | ||
const handleButtonClick = (event: Event) => { | ||
event.preventDefault(); | ||
event.stopPropagation(); | ||
// Manually trigger the action logging | ||
action(actionDescription)(event); | ||
}; | ||
|
||
const buttons = document.querySelectorAll(domQuery); | ||
|
||
// Override the click event handler for each button | ||
buttons.forEach(button => { | ||
button.addEventListener(actionType, handleButtonClick); | ||
}); | ||
|
||
return () => { | ||
// Cleanup: Remove the overridden click event handlers | ||
buttons.forEach(button => { | ||
button.removeEventListener(actionType, handleButtonClick); | ||
}); | ||
}; | ||
}, []); | ||
|
||
return <StoryFn />; | ||
}; | ||
}; | ||
|
||
export default withButtonOverrides; |
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,18 @@ | ||
import React from 'react'; | ||
|
||
import ThemedSkeletonWrapper from '../../src/styles/ThemedSkeletonWrapper'; | ||
import { darkTheme, lightTheme } from '../../src/styles/theme'; | ||
const withLoadingSkeletons = (Story, context) => { | ||
const initialTheme = (context.globals.theme === '' || context.globals.theme ==="dark") ? 'dark' : "light"; | ||
const { | ||
//@ts-ignore | ||
skeleton: { base, highlight }, | ||
} = initialTheme === 'dark' ? darkTheme : lightTheme; | ||
|
||
return ( | ||
<ThemedSkeletonWrapper baseColor={base} highlightColor={highlight}> | ||
<Story /> | ||
</ThemedSkeletonWrapper> | ||
); | ||
}; | ||
export default withLoadingSkeletons; |
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,36 @@ | ||
import React, { useEffect, useState } from 'react'; | ||
|
||
import { useGlobals } from '@storybook/client-api'; | ||
|
||
import { AppContext } from '../../src/pages/_app'; | ||
|
||
const withMockedAppContext = initialTheme => (Story, context) => { | ||
const [theme, setTheme] = useState(initialTheme); | ||
const [globals, setGlobals] = useGlobals(); | ||
const toggleTheme = () => { | ||
setTheme(prevTheme => (prevTheme === 'light' ? 'dark' : 'light')); | ||
}; | ||
const isDocsPage = context.viewMode === 'docs'; | ||
|
||
useEffect(() => { | ||
if (!isDocsPage) { | ||
const initialTheme = (context.globals.theme === '' || context.globals.theme ==="dark") ? 'dark' : "light"; | ||
const newBg = initialTheme === 'dark' ? '#333333' : '#F8F8F8'; | ||
|
||
setGlobals({ | ||
...globals, | ||
backgrounds: { | ||
value: newBg, | ||
}, | ||
}); | ||
} | ||
}, [globals.theme]); | ||
|
||
return ( | ||
<AppContext.Provider value={{ theme, toggleTheme }}> | ||
<Story {...context} /> | ||
</AppContext.Provider> | ||
); | ||
}; | ||
|
||
export default withMockedAppContext; |
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,13 @@ | ||
import React from 'react'; | ||
|
||
import { TourContextProvider } from '../../src/tours/TourContext'; | ||
|
||
const withTourProvider = Story => { | ||
return ( | ||
<TourContextProvider> | ||
<Story /> | ||
</TourContextProvider> | ||
); | ||
}; | ||
|
||
export default withTourProvider; |
Binary file not shown.
Oops, something went wrong.