Skip to content

Commit

Permalink
feat: theme in options
Browse files Browse the repository at this point in the history
  • Loading branch information
atanasster committed Jun 12, 2020
1 parent e4b21af commit 9e4c527
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
9 changes: 8 additions & 1 deletion core/specification/src/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,16 @@ export interface RunConfiguration {
*/
siteImage?: string;

/**
* page types configurations
*/
pages?: PagesConfiguration;

blogsLabel?: string;
/**
* theme-ui theme configuration
*/
theme?: { [key: string]: any };

/**
* story sorting function
*/
Expand Down
6 changes: 5 additions & 1 deletion examples/gatsby/.config/runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ module.exports = {
siteDescription: `Component controls stories. Write your components documentation with MDX and JSX. Design, develop, test and review in a single site.`,
siteLanguage: `en`,
author: `@atanasster`,

theme: {
colors: {
//primary: 'pink',
}
},
storySort: (a, b) => {
const aDoc = a.split('/')[0];
const aIndex = categories.findIndex(c => c === aDoc);
Expand Down
10 changes: 2 additions & 8 deletions integrations/storybook/src/docs-page/DocsContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,12 @@ import {
import { store } from '@component-controls/store/live_store';
import { useIsDark } from '../context/useIsDark';

interface DocsContainerProps {
theme?: Theme;
}
export const PageContextContainer: FC<DocsContainerProps> = ({
children,
theme,
}) => {
export const PageContextContainer: FC = ({ children }) => {
const options = React.useMemo(() => getGlobalOptions(), []);
const storyId = useStoryId();
const isDark = useIsDark();
return (
<ThemeProvider theme={theme} dark={isDark}>
<ThemeProvider theme={store.config?.theme} dark={isDark}>
<BlockContextProvider storyId={storyId} store={store} options={options}>
<BlockPageContainer maxWidth="1000px">{children}</BlockPageContainer>
</BlockContextProvider>
Expand Down
13 changes: 4 additions & 9 deletions ui/app/src/AppContext/AppContext.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
/** @jsx jsx */
import { FC, useMemo } from 'react';
import { jsx } from 'theme-ui';
import {
ThemeProvider,
ThemeProviderProps,
} from '@component-controls/components';
import { ThemeProvider } from '@component-controls/components';
import {
SidebarContextProvider,
LinkContextProvider,
Expand All @@ -15,19 +12,17 @@ import { LoadingStore } from '@component-controls/loader';
import { loadStoryStore, Store } from '@component-controls/store';
import { App } from '../App';

export type AppContextProps = {
export interface AppContextProps {
docId?: string;
store?: LoadingStore;
linkClass: LinkContextProviderProps['linkClass'];
} & ThemeProviderProps;
}

export const AppContext: FC<AppContextProps> = ({
docId,
children,
store,
linkClass,
components,
...themeProps
}) => {
const storyStore = useMemo(
() =>
Expand All @@ -39,7 +34,7 @@ export const AppContext: FC<AppContextProps> = ({
);

return (
<ThemeProvider components={components} {...themeProps}>
<ThemeProvider theme={storyStore.config?.theme}>
<BlockContextProvider docId={docId} store={storyStore}>
<SidebarContextProvider>
<LinkContextProvider linkClass={linkClass}>
Expand Down

0 comments on commit 9e4c527

Please sign in to comment.