-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from squidit/feature/add-more-components
✨ New settings
- Loading branch information
Showing
242 changed files
with
17,187 additions
and
8,566 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 |
---|---|---|
@@ -1,15 +1,47 @@ | ||
import React from 'react' | ||
|
||
export const NdsStyles = (Story) => ( | ||
<div style={{ margin: '3em' }}> | ||
<style> | ||
{` | ||
:root { | ||
--nds-primary-color: 26, 67, 56; | ||
--nds-secondary-color: 0, 101, 83; | ||
}; | ||
`} | ||
</style> | ||
<Story /> | ||
</div> | ||
) | ||
import React, { Suspense, useEffect } from 'react' | ||
import { I18nextProvider } from 'react-i18next' | ||
import i18n from '../src/i18n' | ||
import onThemeChange from './theme-observable' | ||
|
||
export const NdsStyles = (Story, { globals }) => { | ||
const { locale } = globals | ||
|
||
useEffect(() => { | ||
i18n.changeLanguage(locale) | ||
}, [locale]) | ||
|
||
const setThemeForComponents = (theme = 'dark') => { | ||
const html = document.getElementsByTagName('html')[0] | ||
html.classList.remove('light', 'dark') | ||
html.classList.add(theme) | ||
|
||
const docsStoryElements = document.querySelectorAll('.docs-story') | ||
if (docsStoryElements?.length) { | ||
docsStoryElements.forEach((docsStoryElement) => { | ||
docsStoryElement.setAttribute('style', `background-color: var(--background_secondary) !important`) | ||
}) | ||
} | ||
} | ||
|
||
useEffect(() => { | ||
setThemeForComponents(globals?.themeForComponents) | ||
}, [globals?.themeForComponents]) | ||
|
||
return ( | ||
<Suspense fallback={<div>loading translations...</div>}> | ||
<I18nextProvider i18n={i18n}> | ||
<div> | ||
<style> | ||
{` | ||
:root { | ||
--nds-primary-color: 26, 67, 56; | ||
--nds-secondary-color: 0, 101, 83; | ||
}; | ||
`} | ||
</style> | ||
<Story /> | ||
</div> | ||
</I18nextProvider> | ||
</Suspense> | ||
) | ||
} |
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 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,2 @@ | ||
<link rel="shortcut icon" href="https://storage.googleapis.com/web-hub/icons/favicon.ico"> | ||
<link rel="icon" type="image/png" href="https://storage.googleapis.com/web-hub/icons/192x192.png" sizes="192x192"> |
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 |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import { addons } from '@storybook/manager-api' | ||
import squidTheme from './squid.theme' | ||
import { themes } from '@storybook/theming' | ||
import squidThemeDark from './themes/squid-theme-dark' | ||
|
||
addons.setConfig({ | ||
theme: squidTheme, | ||
theme: window.matchMedia('(prefers-color-scheme: dark)').matches ? { ...themes.dark, ...squidThemeDark } : { ...themes.light }, | ||
}) |
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 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,20 @@ | ||
import React, { createContext, useContext, useState } from 'react' | ||
|
||
interface ThemeContextProps { | ||
theme: string | ||
toggleTheme: () => void | ||
} | ||
|
||
export const ThemeContext = createContext<ThemeContextProps | null>(null) | ||
|
||
export const ThemeProvider = ({ children }) => { | ||
const [theme, setTheme] = useState('light') | ||
|
||
const toggleTheme = () => { | ||
setTheme(theme === 'light' ? 'dark' : 'light') | ||
} | ||
|
||
return <ThemeContext.Provider value={{ theme, toggleTheme }}>{children}</ThemeContext.Provider> | ||
} | ||
|
||
export const useTheme = () => useContext(ThemeContext) |
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,2 @@ | ||
import { BehaviorSubject } from 'rxjs' | ||
export default new BehaviorSubject<'light' | 'dark'>('dark') |
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,35 @@ | ||
import { create } from '@storybook/theming' | ||
|
||
export default create({ | ||
base: 'dark', | ||
|
||
brandTitle: 'Squid', | ||
brandUrl: '/', | ||
brandImage: 'https://squidit.com.br/wp-content/themes/squid/assets/img/logo.svg', | ||
brandTarget: '_self', | ||
|
||
colorPrimary: '#ffffff', | ||
colorSecondary: '#b61658', | ||
|
||
// UI | ||
appBg: '#282828', | ||
appContentBg: '#282828', | ||
// appBorderColor: '#585C6D', | ||
appBorderRadius: 4, | ||
|
||
// Text colors | ||
textColor: '#f7f7f7', | ||
textInverseColor: '#f7f7f7', | ||
|
||
// Toolbar default and active colors | ||
barTextColor: '#f7f7f7', | ||
barSelectedColor: '#f7f7f7', | ||
barHoverColor: '#f7f7f7', | ||
barBg: '#282828', | ||
|
||
// Form colors | ||
inputBg: '#282828', | ||
// inputBorder: '#10162F', | ||
inputTextColor: '#f7f7f7', | ||
inputBorderRadius: 2, | ||
}) |
File renamed without changes.
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
Oops, something went wrong.