-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a9ab157
commit bfacd04
Showing
10 changed files
with
96 additions
and
25 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
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,11 @@ | ||
import React, { FC } from 'react'; | ||
import { Title as BaseTitle, TitleProps } from '@component-controls/blocks'; | ||
import { ThemeProvider } from '../shared/ThemeProvider'; | ||
|
||
export const Title: FC<TitleProps> = props => { | ||
return ( | ||
<ThemeProvider> | ||
<BaseTitle {...props} /> | ||
</ThemeProvider> | ||
); | ||
}; |
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,5 +1,6 @@ | ||
export { BlockContextProvider } from './BlockContext'; | ||
export { ComponentSource } from './ComponentSource'; | ||
export { ControlsTable, ControlsTableProps } from './ControlsTable'; | ||
export { Description } from './Description'; | ||
export { StorySource } from './StorySource'; | ||
export { ComponentSource } from './ComponentSource'; | ||
export { BlockContextProvider } from './BlockContext'; | ||
export { Title } from './Title'; |
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,12 +1,16 @@ | ||
import React, { FC } from 'react'; | ||
import styled from '@emotion/styled'; | ||
import { Heading } from 'theme-ui'; | ||
import { Heading, HeadingProps } from 'theme-ui'; | ||
|
||
const StyledHeading = styled(Heading)(() => ({ | ||
fontWeight: 900, | ||
paddingBottom: '25px', | ||
})); | ||
|
||
export const Title: FC = ({ children }) => ( | ||
<StyledHeading as="h1">{children}</StyledHeading> | ||
export type TitleProps = HeadingProps; | ||
|
||
export const Title: FC<TitleProps> = ({ children, ...rest }) => ( | ||
<StyledHeading as="h1" {...rest}> | ||
{children} | ||
</StyledHeading> | ||
); |
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,30 +1,17 @@ | ||
import React from 'react'; | ||
import { Description } from './Description'; | ||
import { BlockContext } from '../BlocksContext'; | ||
import { MockContext } from '../test/MockContext'; | ||
|
||
const MockContext: React.FC = ({ children }) => ( | ||
<BlockContext.Provider | ||
value={{ | ||
currentId: 'blocks-core-description--simple', | ||
storyStore: { | ||
fromId: () => ({ | ||
parameters: { | ||
component: Description, | ||
}, | ||
}), | ||
}, | ||
}} | ||
> | ||
{children} | ||
</BlockContext.Provider> | ||
); | ||
export default { | ||
title: 'Blocks/Core/Description', | ||
component: Description, | ||
}; | ||
|
||
export const simple = () => ( | ||
<MockContext> | ||
<MockContext | ||
storyId="blocks-core-description--simple" | ||
component={Description} | ||
> | ||
<Description of={Description} /> | ||
</MockContext> | ||
); |
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,14 @@ | ||
import React from 'react'; | ||
import { Title } from './'; | ||
import { MockContext } from '../test/MockContext'; | ||
|
||
export default { | ||
title: 'Blocks/Core/Title', | ||
component: Title, | ||
}; | ||
|
||
export const simple = () => ( | ||
<MockContext storyId="blocks-core-description--simple" component={Title}> | ||
<Title /> | ||
</MockContext> | ||
); |
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,23 @@ | ||
import React, { FC } from 'react'; | ||
import { | ||
Title as TitleBlock, | ||
TitleProps as TitlePropsBase, | ||
} from '@component-controls/block-components'; | ||
import { useControlsContext, StoryInputProps } from '../BlocksContext'; | ||
|
||
export type TitleProps = StoryInputProps & TitlePropsBase; | ||
|
||
export const Title: FC<TitleProps> = ({ id, name, ...rest }) => { | ||
const { component, kind } = useControlsContext({ | ||
id, | ||
name, | ||
}); | ||
let title; | ||
if (component && component.info && component.info.displayName) { | ||
title = component.info.displayName; | ||
} else if (kind) { | ||
const titleParts = kind.title.split('/'); | ||
title = titleParts[titleParts.length - 1]; | ||
} | ||
return title ? <TitleBlock {...rest}>{title}</TitleBlock> : null; | ||
}; |
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 @@ | ||
export * from './Title'; |
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,28 @@ | ||
import React from 'react'; | ||
import { BlockContext } from '../BlocksContext'; | ||
|
||
export interface MockContexProps { | ||
storyId?: string; | ||
component?: React.ComponentType; | ||
} | ||
|
||
export const MockContext: React.FC<MockContexProps> = ({ | ||
children, | ||
storyId = 'blocks-core-description--simple', | ||
component = BlockContext, | ||
}) => ( | ||
<BlockContext.Provider | ||
value={{ | ||
currentId: storyId, | ||
storyStore: { | ||
fromId: () => ({ | ||
parameters: { | ||
component, | ||
}, | ||
}), | ||
}, | ||
}} | ||
> | ||
{children} | ||
</BlockContext.Provider> | ||
); |