-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Better reflects the patterns currently used See #81
- Loading branch information
1 parent
0dab0a4
commit 5e027df
Showing
3 changed files
with
38 additions
and
23 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,16 +1,33 @@ | ||
import React from 'react' | ||
import { styled } from 'stitches.config' | ||
import * as Polymorphic from '@radix-ui/react-polymorphic' | ||
import React, { forwardRef } from 'react' | ||
import { CSS, StitchesVariants, styled } from 'stitches.config' | ||
|
||
const DEFAULT_TAG = 'div' | ||
|
||
/** | ||
* {{ name }} component | ||
*/ | ||
export const Styled{{ name }} = styled('div', {}) | ||
* Styled{{ name }} base component | ||
*/ | ||
const Styled{{ name }} = styled(DEFAULT_TAG, {}) | ||
|
||
|
||
type Styled{{ name }}Props = React.ComponentProps<typeof Styled{{ name }}> | ||
export type {{ name }}Props = Styled{{ name }}Props & {} | ||
|
||
|
||
export const {{ name }}: React.FC<{{ name }}Props> = Styled{{ name }} | ||
{{ name }}.toString = () => `.${Styled{{ name }}.className}` | ||
// Either export the component above directly removing the Styled prefix. | ||
// Or if polymorphism is required or further action on the bases component uncomment below. | ||
// | ||
// type {{ name }}CSSProp = { css?: CSS } | ||
// type {{ name }}Variants = StitchesVariants<typeof Styled{{ name }}> | ||
// type {{ name }}OwnProps = {{ name }}CSSProp & {{ name }}Variants | ||
// | ||
// type {{ name }}Component = Polymorphic.ForwardRefComponent< | ||
// typeof DEFAULT_TAG, | ||
// {{ name }}OwnProps | ||
// > | ||
// | ||
// /** | ||
// * {{ name }} component | ||
// */ | ||
// export const {{ name }} = forwardRef(({ ...props }, ref) => ( | ||
// <Styled{{ name }} | ||
// ref={ref} | ||
// {...props} | ||
// /> | ||
// )) as {{ name }}Component | ||
// {{ name }} .toString = () => `.${Styled{{ name }}.className}` |
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,20 +1,19 @@ | ||
import React from 'react' | ||
import { Story, Meta } from '@storybook/react' | ||
import { {{ name }}, {{ name }}Props } from '.' | ||
import { {{ name }} } from '.' | ||
|
||
export default { | ||
title: 'Components/{{ name }}', | ||
component: {{ name }}, | ||
} as Meta | ||
|
||
export const Default: React.FC = () => { | ||
return | ||
<{{ name }} /> | ||
} | ||
export const Default: Story = (args) => <{{ name }} {...args} /> | ||
|
||
const Template: Story<{{ name }}Props> = (args) => | ||
<{{ name }} {...args} /> | ||
// Use for Template args setup | ||
// const Template: Story = (args) => <{{ name }} {...args} /> | ||
// export const Primary = Template.bind({}) | ||
// Primary.args = { | ||
// } | ||
|
||
export const Primary = Template.bind({}) | ||
Primary.args = { | ||
} | ||
// Use for separate stories | ||
// export const Simple: React.FC = () => <{{ name }} /> |
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