Skip to content

Commit

Permalink
feat(core): add white color to button component (#297)
Browse files Browse the repository at this point in the history
  • Loading branch information
felipefialho authored Oct 23, 2023
1 parent efb273b commit cfa8d40
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 34 deletions.
5 changes: 5 additions & 0 deletions packages/core/src/components/button/button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
.atom-button {
text-transform: inherit;

&[color='white'] {
--ion-color-base: var(--color-neutral-white);
--ion-color-contrast: var(--color-neutral-black);
}

&[size='default'] {
--button-size: var(--spacing-xxxxlarge);
font: var(--button-medium);
Expand Down
4 changes: 3 additions & 1 deletion packages/core/src/components/button/button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
shadow: true,
})
export class AtomButton {
@Prop() color: 'primary' | 'secondary' = 'primary'
@Prop() color: 'primary' | 'secondary' | 'white' = 'primary'
@Prop() disabled?: boolean
@Prop() download?: string
@Prop() expand?: 'block'
Expand Down Expand Up @@ -43,10 +43,12 @@ export class AtomButton {
event.stopPropagation()

if (this.loading || this.disabled) return

if (this.type === 'button') {
return this.click.emit(event)
} else {
const form = this.element.closest('form')

if (form) {
return form[this.formFunctions[this.type]]()
}
Expand Down
5 changes: 2 additions & 3 deletions packages/core/src/components/button/stories/button.args.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { withActions } from '@storybook/addon-actions/decorator'

import { Category } from '@atomium/storybook-utils/enums/table'
import { withActions } from '@storybook/addon-actions/decorator'

export const ButtonStoryArgs = {
parameters: {
Expand All @@ -22,7 +21,7 @@ export const ButtonStoryArgs = {
},
color: {
control: 'select',
options: ['primary', 'secondary'],
options: ['primary', 'secondary', 'white'],
defaultValue: { summary: 'primary' },
description: "The color to use from your application's color palette.",
table: {
Expand Down
40 changes: 25 additions & 15 deletions packages/core/src/components/button/stories/button.core.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Meta, StoryObj } from '@storybook/web-components'

import { html } from 'lit'

import { ButtonComponentArgs, ButtonStoryArgs } from './button.args'
Expand All @@ -9,21 +8,23 @@ export default {
...ButtonStoryArgs,
} as Meta

const createButton = (args) => {
const createButton = (args, themeColor = 'light') => {
return html`
<atom-button
color="${args.color}"
fill="${args.fill}"
expand="${args.expand}"
size="${args.size}"
disabled="${args.disabled}"
loading="${args.loading}"
type="${args.type}"
mode="${args.mode}"
shape="${args.shape}"
>
${args.label}
</atom-button>
<div class="theme-${themeColor}">
<atom-button
color="${args.color}"
fill="${args.fill}"
expand="${args.expand}"
size="${args.size}"
disabled="${args.disabled}"
loading="${args.loading}"
type="${args.type}"
mode="${args.mode}"
shape="${args.shape}"
>
${args.label}
</atom-button>
</div>
`
}

Expand All @@ -43,6 +44,15 @@ export const Secondary: StoryObj = {
},
}

export const White: StoryObj = {
render: (args) => createButton(args, 'dark'),
args: {
...Primary.args,
color: 'white',
fill: 'outline',
},
}

export const Text: StoryObj = {
render: (args) => createButton(args),
args: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { AtomButton, AtomIcon } from '@juntossomosmais/atomium/react'
import { Meta, StoryObj } from '@storybook/react'
import React from 'react'

import { AtomButton, AtomIcon } from '@juntossomosmais/atomium/react'

import { ButtonComponentArgs, ButtonStoryArgs } from './button.args'

export default {
Expand All @@ -11,19 +10,21 @@ export default {
...ButtonStoryArgs,
} as Meta

const createButton = (args) => (
<AtomButton
color={args.color}
fill={args.fill}
size={args.size}
disabled={args.disabled}
loading={args.loading}
type={args.type}
mode={args.mode}
expand={args.expand}
>
{args.label}
</AtomButton>
const createButton = (args, themeColor = 'light') => (
<div className={`theme-${themeColor}`}>
<AtomButton
color={args.color}
fill={args.fill}
size={args.size}
disabled={args.disabled}
loading={args.loading}
type={args.type}
mode={args.mode}
expand={args.expand}
>
{args.label}
</AtomButton>
</div>
)

export const Primary: StoryObj = {
Expand All @@ -42,6 +43,15 @@ export const Secondary: StoryObj = {
},
}

export const White: StoryObj = {
render: (args) => createButton(args, 'dark'),
args: {
...Primary.args,
color: 'white',
fill: 'outline',
},
}

export const Text: StoryObj = {
render: (args) => createButton(args),
args: {
Expand Down
4 changes: 4 additions & 0 deletions utils/storybook/preview.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@
.sbdocs-a {
color: var(--color-brand-secondary-regular) !important;
}

.theme-dark {
background-color: var(--color-neutral-black);
}

0 comments on commit cfa8d40

Please sign in to comment.