Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Button with variant link now renders as a link #308

Merged
merged 1 commit into from
Aug 22, 2023
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
11 changes: 6 additions & 5 deletions packages/app-elements/src/ui/atoms/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ const sizeCss: Record<ButtonSize, string> = {
}

const variantCss: Record<ButtonVariant, string> = {
primary: 'bg-black text-white hover:opacity-80',
primary: 'bg-black border border-black text-white hover:opacity-80',
secondary:
'bg-white border border-gray-300 text-black hover:opacity-80 hover:bg-gray-50',
danger: 'bg-white border border-red text-red hover:bg-red/10',
link: 'border border-transparent hover:opacity-80'
link: 'text-primary hover:opacity-80'
}

function Button({
Expand All @@ -50,12 +50,13 @@ function Button({
<button
className={cn([
className,
'text-sm rounded text-center font-bold transition-opacity duration-500 focus:outline-none',
'rounded text-center font-bold focus:outline-none',
{
'opacity-50 pointer-events-none touch-none': disabled,
'w-full': fullWidth === true
'w-full': fullWidth === true,
[`text-sm transition-opacity duration-500 ${sizeCss[size]}`]:
variant !== 'link'
},
sizeCss[size],
variantCss[variant]
])}
disabled={disabled}
Expand Down
6 changes: 2 additions & 4 deletions packages/app-elements/src/ui/resources/LineItems.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const Edit = withSkeletonTemplate<{
<Button
aria-label='Delete'
disabled={disabled}
className='!p-0'
className='block'
variant='link'
onClick={() => {
if (!disabled) {
Expand All @@ -77,9 +77,7 @@ const Edit = withSkeletonTemplate<{
}
}}
>
<Text variant={disabled ? 'disabled' : 'primary'} weight='bold'>
<Trash size={18} weight='bold' />
</Text>
<Trash size={18} weight='bold' />
</Button>
)}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,23 +346,19 @@ exports[`LineItems > should render the InputSpinner and the trash icon when edit
<div>
<button
aria-label="Delete"
class="!p-0 text-sm rounded text-center font-bold transition-opacity duration-500 focus:outline-none px-6 py-3 border border-transparent hover:opacity-80"
class="block rounded text-center font-bold focus:outline-none text-primary hover:opacity-80"
>
<span
class="text-primary font-bold [overflow-wrap:anywhere]"
<svg
fill="currentColor"
height="18"
viewBox="0 0 256 256"
width="18"
xmlns="http://www.w3.org/2000/svg"
>
<svg
fill="currentColor"
height="18"
viewBox="0 0 256 256"
width="18"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M216,48H180V36A28,28,0,0,0,152,8H104A28,28,0,0,0,76,36V48H40a12,12,0,0,0,0,24h4V208a20,20,0,0,0,20,20H192a20,20,0,0,0,20-20V72h4a12,12,0,0,0,0-24ZM100,36a4,4,0,0,1,4-4h48a4,4,0,0,1,4,4V48H100Zm88,168H68V72H188ZM116,104v64a12,12,0,0,1-24,0V104a12,12,0,0,1,24,0Zm48,0v64a12,12,0,0,1-24,0V104a12,12,0,0,1,24,0Z"
/>
</svg>
</span>
<path
d="M216,48H180V36A28,28,0,0,0,152,8H104A28,28,0,0,0,76,36V48H40a12,12,0,0,0,0,24h4V208a20,20,0,0,0,20,20H192a20,20,0,0,0,20-20V72h4a12,12,0,0,0,0-24ZM100,36a4,4,0,0,1,4-4h48a4,4,0,0,1,4,4V48H100Zm88,168H68V72H188ZM116,104v64a12,12,0,0,1-24,0V104a12,12,0,0,1,24,0Zm48,0v64a12,12,0,0,1-24,0V104a12,12,0,0,1,24,0Z"
/>
</svg>
</button>
</div>
</div>
Expand Down
23 changes: 20 additions & 3 deletions packages/docs/src/stories/atoms/Button.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,39 @@
import { A } from '#ui/atoms/A'
import { Button } from '#ui/atoms/Button'
import { type Meta, type StoryFn } from '@storybook/react'

const setup: Meta<typeof Button> = {
title: 'Atoms/Button',
component: Button
component: Button,
parameters: {
layout: 'padded'
}
}
export default setup

const Template: StoryFn<typeof Button> = (args) => <Button {...args} />
const Template: StoryFn<typeof Button> = (args) => (
<div>
<Button {...args} />
</div>
)

export const Primary = Template.bind({})
Primary.args = {
variant: 'primary',
children: 'Hello'
children: 'Hello',
disabled: false
}

export const Danger = Template.bind({})
Danger.args = {
variant: 'danger',
children: 'Delete webhook'
}

export const Link: StoryFn = (args) => (
<div>
<Button variant='link'>I am a button</Button>
<br />
<A onClick={() => {}}>I am a link</A>
</div>
)