Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ yarn add reakit theme-ui

```tsx
import React from 'react'
import Button from '@vtex-component/button'
import Button from '@vtex-components/button'

function Example() {
return <Button>Button Label</Button>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vtex-components/button",
"version": "1.0.1",
"version": "1.1.0",
"description": "VTEX button component",
"author": "vtex",
"license": "MIT",
Expand Down
21 changes: 21 additions & 0 deletions src/Button.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react'
import { ThemeProvider } from 'theme-ui'
import { withA11y } from '@storybook/addon-a11y'
import { withKnobs, text, color, boolean } from '@storybook/addon-knobs'
import { Checkbox, useCheckboxState } from 'reakit'

import Button from '.'

Expand Down Expand Up @@ -45,6 +46,26 @@ export function TheSXProp() {
)
}

export function TheAsProp() {
const checkbox = useCheckboxState()

return (
<ThemeProvider
theme={{
colors: {
background: '#FFFFFF',
primary: '#2F323A',
secondary: '#4F5D75',
},
}}
>
<Checkbox {...checkbox} as={Button}>
{checkbox.state ? '😄 Happy' : '😞 Sad'}
</Checkbox>
</ThemeProvider>
)
}

export function Theming() {
const theme = {
colors: {
Expand Down
4 changes: 2 additions & 2 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import {

type Props = A11yProps & ThemeAwareProps

function Button(props: Props, ref: Ref<HTMLButtonElement>) {
return <A11yButton {...props} ref={ref} as={ThemeAwareButton} />
function Button({ as, ...props }: Props, ref: Ref<HTMLButtonElement>) {
return <A11yButton {...props} ref={ref} as={as ?? ThemeAwareButton} />
}

export { A11yProps, ThemeAwareProps }
Expand Down