Skip to content

Commit 03baeb7

Browse files
committed
feat: variable size buttons
1 parent 46eb1f0 commit 03baeb7

File tree

8 files changed

+158
-83
lines changed

8 files changed

+158
-83
lines changed

.changeset/all-hairs-run.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@scouterna/ui-react": patch
3+
"@scouterna/ui-webc": patch
4+
---
5+
6+
Variable size buttons

packages/ui-react/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
},
2828
"devDependencies": {
2929
"@types/react": "^19.2.7",
30-
"react": "^19.2.1",
31-
"react-dom": "^19.2.1",
30+
"react": "^19.2.3",
31+
"react-dom": "^19.2.3",
3232
"typescript": "^5.9.3"
3333
}
3434
}

packages/ui-webc/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,18 +55,18 @@
5555
"class-variance-authority": "^0.7.1",
5656
"clsx": "^2.1.1",
5757
"iconoir": "^7.11.0",
58-
"@tabler/icons": "^3.35.0"
58+
"@tabler/icons": "^3.36.1"
5959
},
6060
"devDependencies": {
6161
"@stencil-community/postcss": "^2.2.0",
62-
"@stencil/core": "^4.38.3",
62+
"@stencil/core": "^4.41.1",
6363
"@types/jest": "^30.0.0",
6464
"@types/node": "^24.10.1",
6565
"jest": "^30.2.0",
6666
"jest-cli": "^30.2.0",
6767
"postcss-import": "^16.1.1",
68-
"postcss-preset-env": "^10.5.0",
69-
"puppeteer": "^24.32.0"
68+
"postcss-preset-env": "^10.6.0",
69+
"puppeteer": "^24.34.0"
7070
},
7171
"license": "MIT"
7272
}

packages/ui-webc/src/components/button/button.css

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,33 @@
11
scout-button {
22
display: inline-block;
33
height: var(--spacing-10);
4+
font: var(--type-body-base);
5+
6+
&[data-size="large"] {
7+
height: var(--spacing-12);
8+
font: var(--type-body-lg);
9+
}
410

511
.button {
612
flex: 1;
713
display: inline-flex;
14+
width: 100%;
815
height: 100%;
916
align-items: center;
1017
justify-content: center;
1118
gap: var(--spacing-3);
1219
padding: 0 var(--spacing-4);
13-
font: var(--type-body-base);
1420
border-radius: var(--spacing-2);
1521
border: 1px solid transparent;
1622
cursor: pointer;
1723
text-decoration: none;
1824
box-sizing: border-box;
1925
}
2026

27+
&[data-size="large"] .button {
28+
padding: 0 var(--spacing-5);
29+
}
30+
2131
.icon {
2232
width: var(--spacing-5);
2333
height: var(--spacing-5);
@@ -29,17 +39,17 @@ scout-button {
2939
height: 100%;
3040
}
3141

32-
&.icon-only .button {
42+
&[data-icon-only] .button {
3343
aspect-ratio: 1 / 1;
3444
justify-content: center;
3545
padding: 0;
3646
}
3747

38-
&.icon-only .icon {
48+
&[data-icon-only] .icon {
3949
margin: 0;
4050
}
4151

42-
&.icon-only .content {
52+
&[data-icon-only] .content {
4353
/* Visually hidden: https://www.a11yproject.com/posts/how-to-hide-content/ */
4454
clip: rect(0 0 0 0);
4555
clip-path: inset(50%);

packages/ui-webc/src/components/button/button.tsx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@ import {
22
Component,
33
Event,
44
type EventEmitter,
5-
h,
65
Host,
6+
h,
77
Prop,
88
} from "@stencil/core";
99

10+
export type Size = "medium" | "large";
1011
export type Variant = "primary" | "outlined" | "text" | "caution" | "danger";
1112

1213
/**
@@ -25,6 +26,11 @@ export class ScoutButton {
2526
@Prop() target?: string;
2627
@Prop() rel?: string;
2728

29+
/**
30+
* Size of the button.
31+
*/
32+
@Prop() size: Size = "medium";
33+
2834
/**
2935
* The variant primarily affects the color of the button.
3036
*/
@@ -59,7 +65,12 @@ export class ScoutButton {
5965
const icon = this.icon && <span class="icon" innerHTML={this.icon} />;
6066

6167
return (
62-
<Host class={this.iconOnly ? "icon-only" : ""}>
68+
<Host
69+
// Using data- attributes instead of classes because React fights and
70+
// removes them sometimes. Hopefully we can find a proper fix later.
71+
data-size={this.size}
72+
data-icon-only={this.iconOnly}
73+
>
6374
<Tag
6475
class={`button ${this.variant}`}
6576
onClick={() => this.scoutClick.emit()}

packages/ui-webc/src/components/button/readme.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Will render a `<button>` element when the `type` is set to "button",
2020
| `iconOnly` | `icon-only` | | `boolean` | `false` |
2121
| `iconPosition` | `icon-position` | | `"after" \| "before"` | `"after"` |
2222
| `rel` | `rel` | | `string` | `undefined` |
23+
| `size` | `size` | Size of the button. | `"large" \| "medium"` | `"medium"` |
2324
| `target` | `target` | | `string` | `undefined` |
2425
| `type` | `type` | | `"button" \| "link" \| "reset" \| "submit"` | `"button"` |
2526
| `variant` | `variant` | The variant primarily affects the color of the button. | `"caution" \| "danger" \| "outlined" \| "primary" \| "text"` | `"outlined"` |

packages/ui-webc/src/components/input/input.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ import {
88
} from "@stencil/core";
99
import { inputMixin } from "../../mixins/inputMixin";
1010

11+
export type Size = "medium" | "large";
12+
export type Variant = "default" | "elevated";
13+
1114
export type InputType =
1215
| "text"
1316
| "password"
@@ -50,14 +53,14 @@ export class ScoutInput
5053
* inputs, such as a top search field on a page, while medium fields are used
5154
* for regular form inputs.
5255
*/
53-
@Prop() size: "medium" | "large" = "medium";
56+
@Prop() size: Size = "medium";
5457

5558
/**
5659
* Visual variant of the input element. Elevated inputs have a shadow to help
5760
* them stand out from the background and should only be used when absolutely
5861
* positioned above other content.
5962
*/
60-
@Prop() variant: "default" | "elevated" = "default";
63+
@Prop() variant: Variant = "default";
6164

6265
/**
6366
* Type of input element. If you need a number input, read the accessibility

0 commit comments

Comments
 (0)