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

feat!: button v11 #1895

Open
wants to merge 6 commits into
base: next/v11-styles
Choose a base branch
from
Open
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
8 changes: 4 additions & 4 deletions COMPONENT_INDEX.md
Original file line number Diff line number Diff line change
Expand Up @@ -429,10 +429,10 @@ None.

### Props

| Prop name | Required | Kind | Reactive | Type | Default value | Description |
| :-------- | :------- | :--------------- | :------- | ---------------------------------------------------------------------------- | ---------------------- | ------------------------------------ |
| href | No | <code>let</code> | No | <code>string</code> | <code>undefined</code> | Set the `href` to use an anchor link |
| size | No | <code>let</code> | No | <code>"default" &#124; "field" &#124; "small" &#124; "lg" &#124; "xl"</code> | <code>"default"</code> | Specify the size of button skeleton |
| Prop name | Required | Kind | Reactive | Type | Default value | Description |
| :-------- | :------- | :--------------- | :------- | ------------------------------------------------------------------ | ---------------------- | ------------------------------------ |
| href | No | <code>let</code> | No | <code>string</code> | <code>undefined</code> | Set the `href` to use an anchor link |
| size | No | <code>let</code> | No | <code>"sm" &#124; "md" &#124; "lg" &#124; "xl" &#124; "2xl"</code> | <code>"lg"</code> | Specify the size of button skeleton |

### Slots

Expand Down
6 changes: 3 additions & 3 deletions css/all.css

Large diffs are not rendered by default.

23 changes: 10 additions & 13 deletions css/all.scss
Original file line number Diff line number Diff line change
@@ -1,35 +1,32 @@
$prefix: 'bx';

// Use all Carbon themes
@use '@carbon/styles/scss/config' with (
$use-akamai-cdn: true,
$prefix: 'bx'
$prefix: $prefix
);
@use "@carbon/styles/scss/theme" as *;
@use "@carbon/styles/scss/themes" as *;
@use "@carbon/styles/scss/fonts";
@use "@carbon/styles" as styles;
@use "@carbon/styles/scss/utilities" as *;

:root {
@include theme($white);
@include styles.theme(styles.$white);
}

[data-carbon-theme='g10'] {
@include theme($g10);
@include styles.theme(styles.$g10);
}

[data-carbon-theme='g90'] {
@include theme($g90);
@include styles.theme(styles.$g90);
}

[data-carbon-theme='g100'] {
@include theme($g100);
@include styles.theme(styles.$g100);
}

@import "@carbon/styles/scss/reset";
@import "@carbon/styles/scss/components";

.bx--text-truncate-end {
.#{$prefix}--text-truncate-end {
@include text-truncate-end;
}
.bx--text-truncate-front {
.#{$prefix}--text-truncate-front {
@include text-truncate-front;
}
6 changes: 3 additions & 3 deletions css/g10.css

Large diffs are not rendered by default.

10 changes: 2 additions & 8 deletions css/g10.scss
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
// Use g10 theme
@use '@carbon/styles/scss/config' with (
$use-akamai-cdn: true,
$prefix: 'bx'
);
@use "@carbon/styles/scss/theme" as *;
@use "@carbon/styles/scss/themes" as *;
@use "@carbon/styles/scss/fonts";
@use "@carbon/styles" as styles;
@use "@carbon/styles/scss/utilities" as *;

:root {
@include theme($g10);
@include styles.theme(styles.$g10);
}

@import "@carbon/styles/scss/reset";
@import "@carbon/styles/scss/components";

.bx--text-truncate-end {
@include text-truncate-end;
}
Expand Down
6 changes: 3 additions & 3 deletions css/g100.css

Large diffs are not rendered by default.

10 changes: 2 additions & 8 deletions css/g100.scss
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
// Use g10 theme
@use '@carbon/styles/scss/config' with (
$use-akamai-cdn: true,
$prefix: 'bx'
);
@use "@carbon/styles/scss/theme" as *;
@use "@carbon/styles/scss/themes" as *;
@use "@carbon/styles/scss/fonts";
@use "@carbon/styles" as styles;
@use "@carbon/styles/scss/utilities" as *;

:root {
@include theme($g100);
@include styles.theme(styles.$g100);
}

@import "@carbon/styles/scss/reset";
@import "@carbon/styles/scss/components";

.bx--text-truncate-end {
@include text-truncate-end;
}
Expand Down
6 changes: 3 additions & 3 deletions css/g90.css

Large diffs are not rendered by default.

10 changes: 2 additions & 8 deletions css/g90.scss
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
// Use g10 theme
@use '@carbon/styles/scss/config' with (
$use-akamai-cdn: true,
$prefix: 'bx'
);
@use "@carbon/styles/scss/theme" as *;
@use "@carbon/styles/scss/themes" as *;
@use "@carbon/styles/scss/fonts";
@use "@carbon/styles" as styles;
@use "@carbon/styles/scss/utilities" as *;

:root {
@include theme($g90);
@include styles.theme(styles.$g90);
}

@import "@carbon/styles/scss/reset";
@import "@carbon/styles/scss/components";

.bx--text-truncate-end {
@include text-truncate-end;
}
Expand Down
10 changes: 5 additions & 5 deletions docs/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions docs/src/COMPONENT_API.json
Original file line number Diff line number Diff line change
Expand Up @@ -704,8 +704,8 @@
"name": "size",
"kind": "let",
"description": "Specify the size of button skeleton",
"type": "\"default\" | \"field\" | \"small\" | \"lg\" | \"xl\"",
"value": "\"default\"",
"type": "\"sm\" | \"md\" | \"lg\" | \"xl\" | \"2xl\"",
"value": "\"lg\"",
"isFunction": false,
"isFunctionDeclaration": false,
"isRequired": false,
Expand Down
67 changes: 23 additions & 44 deletions docs/src/pages/components/Button.svx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

<InlineNotification svx-ignore lowContrast title="Note:" kind="info" hideCloseButton>
<div class="body-short-01">
You must provide an <strong>iconDescription</strong> for the button tooltip.
You must provide an <strong>iconDescription</strong> for screen readers.
</div>
</InlineNotification>

Expand All @@ -54,7 +54,7 @@

<InlineNotification svx-ignore lowContrast title="Note:" kind="info" hideCloseButton>
<div class="body-short-01">
You must provide an <strong>iconDescription</strong> for the button tooltip.
You must provide an <strong>iconDescription</strong> for screen readers.
</div>
</InlineNotification>

Expand Down Expand Up @@ -84,41 +84,20 @@ If an `href` value is specified, the component will render an [anchor element](h

## Custom element

<Button as let:props>
<p {...props}>Custom element</p>
<Button as="div">
Custom element
</Button>

## Field size
## Sizes

<Button size="md">Primary</Button>
<Button size="md" kind="secondary">Secondary</Button>
<Button size="md" kind="tertiary">Tertiary</Button>
<Button size="md" kind="ghost">Ghost</Button>
<Button size="md" kind="danger">Danger</Button>
Button is available in small, medium, large, extra-large, and double-extra-large.
Use `md` (default) when used with form fields.

## Small size

<Button size="sm">Primary</Button>
<Button size="sm" kind="secondary">Secondary</Button>
<Button size="sm" kind="tertiary">Tertiary</Button>
<Button size="sm" kind="ghost">Ghost</Button>
<Button size="sm" kind="danger">Danger</Button>

## Large size

<Button size="xl">Primary</Button>
<Button size="xl" kind="secondary">Secondary</Button>
<Button size="xl" kind="tertiary">Tertiary</Button>
<Button size="xl" kind="ghost">Ghost</Button>
<Button size="xl" kind="danger">Danger</Button>

## Extra-large size

<Button size="2xl">Primary</Button>
<Button size="2xl" kind="secondary">Secondary</Button>
<Button size="2xl" kind="tertiary">Tertiary</Button>
<Button size="2xl" kind="ghost">Ghost</Button>
<Button size="2xl" kind="danger">Danger</Button>
<Button size="sm">Small</Button>
<Button size="md">Medium</Button>
<Button size="lg">Large</Button>
<Button size="xl">Extra Large</Button>
<Button size="2xl">Double extra Large</Button>

## Disabled state

Expand All @@ -129,12 +108,6 @@ If an `href` value is specified, the component will render an [anchor element](h

Set `expressive` to `true` to use Carbon's expressive typesetting.

<InlineNotification svx-ignore lowContrast title="Note:" kind="info" hideCloseButton>
<div class="body-short-01">
Expressive styles only work with the default, "lg", and "xl" button sizes.
</div>
</InlineNotification>

<Button expressive size="xl">Primary</Button>
<Button expressive size="xl" kind="secondary">Secondary</Button>
<Button expressive size="xl" kind="tertiary">Tertiary</Button>
Expand All @@ -153,13 +126,19 @@ Set `expressive` to `true` to use Carbon's expressive typesetting.
<Button expressive kind="ghost">Ghost</Button>
<Button expressive kind="danger">Danger</Button>

## Additional attributes

Use `buttonAttributes` to pass any additional attributes.

<Button buttonAttributes={{class: 'ready'}}>Ready</Button>

## Skeleton

<Button size="xl" skeleton />
<Button size="lg" skeleton />
<Button skeleton />
<Button skeleton size="field" />
<Button skeleton size="small" />
<Button skeleton size="2xl" />
<Button skeleton size="xl" />
<Button skeleton size="lg" />
<Button skeleton size="md" />
<Button skeleton size="sm" />

## Programmatic focus

Expand Down
12 changes: 2 additions & 10 deletions src/Button/Button.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -97,16 +97,8 @@
class: [
"bx--btn",
expressive && "bx--btn--expressive",
((size === "small" && !expressive) ||
(size === "sm" && !expressive) ||
(size === "small" && !expressive)) &&
"bx--btn--sm",
((size === "field" && !expressive) || (size === "md" && !expressive)) &&
"bx--btn--md",
size === "small" && "bx--btn--sm",
size === "xl" && "bx--btn--xl",
size === "2xl" && "bx--btn--2xl",
kind && `bx--btn--${kind}`,
`bx--layout--size-${size}`,
`bx--btn--${kind}`,
disabled && "bx--btn--disabled",
hasIconOnly && "bx--btn--icon-only",
hasIconOnly && "bx--tooltip__trigger",
Expand Down
22 changes: 12 additions & 10 deletions src/Button/ButtonSkeleton.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

/**
* Specify the size of button skeleton
* @type {"default" | "field" | "small" | "lg" | "xl"}
* @type {"sm" | "md" | "lg" | "xl" | "2xl"}
*/
export let size = "default";
export let size = "lg";
</script>

<!-- svelte-ignore a11y-mouse-events-have-key-events -->
Expand All @@ -20,10 +20,11 @@
role="button"
class:bx--skeleton="{true}"
class:bx--btn="{true}"
class:bx--btn--field="{size === 'field'}"
class:bx--btn--sm="{size === 'small'}"
class:bx--btn--lg="{size === 'lg'}"
class:bx--btn--xl="{size === 'xl'}"
class:bx--layout--size-sm="{size === 'sm'}"
class:bx--layout--size-md="{size === 'md'}"
class:bx--layout--size-lg="{size === 'lg'}"
class:bx--layout--size-xl="{size === 'xl'}"
class:bx--layout--size-2xl="{size === '2xl'}"
{...$$restProps}
on:click
on:focus
Expand All @@ -39,10 +40,11 @@
<div
class:bx--skeleton="{true}"
class:bx--btn="{true}"
class:bx--btn--field="{size === 'field'}"
class:bx--btn--sm="{size === 'small'}"
class:bx--btn--lg="{size === 'lg'}"
class:bx--btn--xl="{size === 'xl'}"
class:bx--layout--size-sm="{size === 'sm'}"
class:bx--layout--size-md="{size === 'md'}"
class:bx--layout--size-lg="{size === 'lg'}"
class:bx--layout--size-xl="{size === 'xl'}"
class:bx--layout--size-2xl="{size === '2xl'}"
{...$$restProps}
on:click
on:focus
Expand Down
4 changes: 2 additions & 2 deletions types/Button/ButtonSkeleton.svelte.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ export interface ButtonSkeletonProps extends RestProps {

/**
* Specify the size of button skeleton
* @default "default"
* @default "lg"
*/
size?: "default" | "field" | "small" | "lg" | "xl";
size?: "sm" | "md" | "lg" | "xl" | "2xl";

[key: `data-${string}`]: any;
}
Expand Down