Skip to content

Commit a1f27b7

Browse files
committed
feat: add form component with tweaked select and button styles
1 parent 8df2b54 commit a1f27b7

File tree

6 files changed

+117
-3
lines changed

6 files changed

+117
-3
lines changed

src/scss/components/_index.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
@forward "country-switcher/country-switcher";
77
@forward "data-card/data-card";
88
@forward "figures/figures";
9+
@forward "form/form";
910
@forward "piped-list/piped-list";
1011
@forward "icon/icon";
1112
@forward "jump-menu/jump-menu";

src/scss/components/button/_button.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454

5555
&--pill {
5656
color: $color-grey-90;
57-
background-color: $color-teal-20;
57+
background-color: $color-teal-10;
5858
border: 1px solid $color-teal-50;
5959
padding-top: 0.5rem;
6060
padding-bottom: 0.5rem;
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
@use "../../tokens/color" as *;
2+
@use "../../tokens/font" as *;
3+
@use "../../base/mixins";
4+
@use "../../tokens/screens" as *;
5+
6+
.iati-form {
7+
color: $color-grey-90;
8+
9+
min-width: min(31.25rem, calc(100vw - 2rem));
10+
@media (min-width: $screen-md) {
11+
grid-template-columns: max-content 1fr;
12+
}
13+
14+
&__inner {
15+
background-color: $color-teal-20;
16+
border: 1px solid $color-teal-50;
17+
display: grid;
18+
gap: 1rem;
19+
padding: 1rem;
20+
}
21+
22+
&__item {
23+
display: grid;
24+
grid-template-columns: subgrid;
25+
grid-column: 1 / -1;
26+
align-items: start;
27+
gap: 0.2rem;
28+
@media (min-width: $screen-md) {
29+
gap: 1rem;
30+
}
31+
}
32+
33+
&__label {
34+
font-weight: 600;
35+
grid-column: 1 / -1;
36+
@media (min-width: $screen-md) {
37+
text-align: start;
38+
}
39+
}
40+
41+
&__input {
42+
max-width: 100%;
43+
border: 1px solid $color-teal-50;
44+
background-color: #fff;
45+
padding: 0.5em 1em;
46+
grid-column: -1 / 1;
47+
}
48+
49+
&__submit {
50+
margin: 1rem 0;
51+
max-width: 100%;
52+
min-width: 6rem;
53+
}
54+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import type { Meta, StoryObj } from "@storybook/web-components";
2+
import { html } from "lit";
3+
4+
import "../select/multi-select.ts";
5+
6+
const meta: Meta = {
7+
title: "Components/Form",
8+
parameters: {
9+
backgrounds: {
10+
default: "light",
11+
},
12+
},
13+
};
14+
15+
export default meta;
16+
type Story = StoryObj;
17+
18+
export const Default: Story = {
19+
render: () => html`
20+
<form class="iati-form">
21+
<div class="iati-form__inner">
22+
<div class="iati-form__item">
23+
<label for="search-input" class="iati-form__label"
24+
>Search for items containing:</label
25+
>
26+
<input id="search-input" type="text" class="iati-form__input" />
27+
</div>
28+
<div class="iati-form__item">
29+
<div class="iati-select">
30+
<label for="iati-single-select" class="iati-select__label">
31+
Choose your language
32+
</label>
33+
<div class="iati-select__control-wrapper">
34+
<select id="iati-single-select" class="iati-select__control">
35+
<option>English</option>
36+
<option>French</option>
37+
</select>
38+
</div>
39+
</div>
40+
</div>
41+
<div class="iati-form__item">
42+
<multi-select
43+
.label=${"Choose your language(s)"}
44+
.options=${["English", "French"]}
45+
></multi-select>
46+
</div>
47+
</div>
48+
<button class="iati-form__submit iati-button iati-button--submit">
49+
Search
50+
</button>
51+
</form>
52+
`,
53+
};

src/scss/components/select/_select.scss

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
@use "../../tokens/font" as *;
33

44
.iati-select {
5-
color: currentColor;
5+
color: $color-grey-90;
66

77
&__label {
88
display: block;
@@ -11,7 +11,7 @@
1111

1212
&__control-wrapper {
1313
position: relative;
14-
display: inline-block;
14+
width: 100%;
1515

1616
&::after {
1717
position: absolute;
@@ -27,6 +27,7 @@
2727
}
2828

2929
&__control {
30+
display: inline-block;
3031
padding: 0.7em 2.1em 0.7em 0.7em;
3132
font-family: $font-stack-heading;
3233
line-height: 1.1;

src/scss/components/select/select.stories.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ import "./multi-select.ts";
55

66
const meta: Meta = {
77
title: "Components/Select",
8+
parameters: {
9+
backgrounds: {
10+
default: "light",
11+
},
12+
},
813
argTypes: {
914
label: { control: "text" },
1015
options: { control: "object" },

0 commit comments

Comments
 (0)