Skip to content

Commit

Permalink
[components] Add size property to DefaultButton for adjusting text …
Browse files Browse the repository at this point in the history
…size
  • Loading branch information
mariuslundgard authored and rexxars committed Oct 6, 2020
1 parent 0d07a31 commit f6c20d2
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 3 deletions.
7 changes: 5 additions & 2 deletions packages/@sanity/components/src/buttons/createButtonLike.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ export default function createButtonLike(Component, {displayName, defaultProps =
tabIndex: PropTypes.number,
padding: PropTypes.oneOf(['large', 'default', 'small', 'none']),
bleed: PropTypes.bool,
selected: PropTypes.bool
selected: PropTypes.bool,
size: PropTypes.oneOf(['extra-small', 'small', 'medium', 'large', 'extra-large'])
}

static defaultProps = {
Expand Down Expand Up @@ -82,6 +83,7 @@ export default function createButtonLike(Component, {displayName, defaultProps =
padding,
bleed,
selected,
size,
...rest
} = this.props

Expand All @@ -90,7 +92,8 @@ export default function createButtonLike(Component, {displayName, defaultProps =
styles[kind],
styles[`padding_${padding}`],
inverted && styles.inverted,
color && styles[`color__${color}`],
styles[`color__${color}`],
styles[`size__${size}`],
bleed && styles.bleed,
disabled && styles.disabled,
selected && styles.selected,
Expand Down
8 changes: 7 additions & 1 deletion packages/@sanity/components/src/buttons/stories/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,13 @@ export function DefaultStory() {
icon: boolean('Icon', undefined, 'props') ? TrashIcon : undefined,
padding: select('Padding', ['large', 'default', 'small', 'none'], 'default', 'props'),
bleed: boolean('Bleed', false, 'props'),
selected: boolean('Selected', false, 'props')
selected: boolean('Selected', false, 'props'),
size: select(
'Size',
[undefined, 'extra-small', 'small', 'medium', 'large', 'extra-large'],
undefined,
'props'
)
}

const children = text('Text', 'Touch Me!', 'props')
Expand Down
26 changes: 26 additions & 0 deletions packages/@sanity/components/src/buttons/styles/DefaultButton.css
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,32 @@
@nest &.loading > .inner {
overflow: hidden;
}

@nest &.size__extra-small {
font-size: var(--font-size-xsmall);
line-height: var(--line-height-xsmall);
}

@nest &.size__small {
font-size: var(--font-size-small);
line-height: var(--line-height-small);
}

@nest &.size__medium {
/* default */
/* font-size: var(--font-size-base); */
/* line-height: var(--line-height-base); */
}

@nest &.size__large {
font-size: var(--font-size-large);
line-height: var(--line-height-large);
}

@nest &.size__extra-large {
font-size: var(--font-size-huge);
line-height: var(--line-height-huge);
}
}

.inner {
Expand Down

0 comments on commit f6c20d2

Please sign in to comment.