Skip to content

Commit facb5e9

Browse files
committed
Checkbox component, adjustments in Input/dropdown
1 parent 920dda5 commit facb5e9

File tree

5 files changed

+93
-2
lines changed

5 files changed

+93
-2
lines changed

src/Checkbox/Checkbox.stories.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { ComponentMeta, ComponentStory } from "@storybook/react";
2+
import { iconsArray } from "../Icon/types";
3+
import CheckboxComponent from ".";
4+
import { CheckboxProps } from "./types";
5+
6+
export default {
7+
title: "User Interface/Checkbox",
8+
component: CheckboxComponent,
9+
} as ComponentMeta<typeof CheckboxComponent>;
10+
11+
const Template: ComponentStory<typeof CheckboxComponent> = (args: CheckboxProps) => <CheckboxComponent {...args} />;
12+
13+
export const Checkbox = Template.bind({});
14+
Checkbox.args = {
15+
label: "Text",
16+
};

src/Checkbox/index.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import classes from "../utils/classes";
2+
import { CheckboxProps } from "./types";
3+
import style from "./style/Checkbox.module.scss";
4+
5+
export default function Checkbox({ label, className, ...props }: CheckboxProps) {
6+
const containerClasses = classes([style.container, className]);
7+
8+
return (
9+
<label className={containerClasses}>
10+
<input type="checkbox" {...props} />
11+
<span>{label}</span>
12+
</label>
13+
);
14+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
.container {
2+
display: inline-block;
3+
display: flex;
4+
gap: var(--m-xs);
5+
align-items: center;
6+
7+
&:has(input:not(:disabled)) {
8+
cursor: pointer;
9+
}
10+
11+
input[type="checkbox"] {
12+
-webkit-appearance: none;
13+
appearance: none;
14+
background-color: transparent;
15+
margin: 0;
16+
color: var(--color-primary);
17+
width: var(--m);
18+
height: var(--m);
19+
border: 2px solid var(--color-border);
20+
display: grid;
21+
place-content: center;
22+
border-radius: var(--border-radius-1);
23+
cursor: pointer;
24+
25+
&::before {
26+
content: "";
27+
width: var(--m-xs);
28+
height: var(--m-xs);
29+
}
30+
31+
&:checked {
32+
background-color: var(--color-primary);
33+
border-color: var(--color-primary);
34+
}
35+
36+
&:checked::before {
37+
clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%);
38+
box-shadow: inset 1em 1em var(--color-input-background);
39+
}
40+
41+
&:not(:disabled) {
42+
&:focus {
43+
outline: 1px solid var(--color-border);
44+
outline-offset: 3px;
45+
}
46+
}
47+
48+
&:disabled {
49+
--container-color: var(--container-disabled);
50+
color: var(--container-disabled);
51+
cursor: default;
52+
background-color: var(--color-input-disabled);
53+
}
54+
}
55+
}

src/Checkbox/types/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { InputHTMLAttributes, ReactElement } from "react";
2+
3+
export type CheckboxProps = InputHTMLAttributes<HTMLInputElement> & {
4+
label?: string | ReactElement;
5+
};

src/Input/style/Input.module.scss

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
.inputWrapper {
3131
background-color: var(--color-input-background);
3232
border-radius: var(--border-radius-2);
33-
outline: 2px solid transparent;
33+
outline: 1px solid transparent;
3434
padding: calc(var(--m-xxs) / 2);
3535
border: 1px solid var(--color-border);
3636
font-weight: 400;
@@ -172,12 +172,13 @@
172172
background-color: var(--color-input-background);
173173
border-radius: var(--border-radius-2);
174174
padding: var(--m-xxxxs);
175-
outline: 2px solid var(--color-text);
175+
outline: 1px solid var(--color-border);
176176
display: flex;
177177
flex-direction: column;
178178
gap: var(--m-xxxxs);
179179
max-height: calc(100vh - 8px);
180180
overflow-y: auto;
181+
margin-top: var(--m-xxxxs);
181182
}
182183

183184
.option {

0 commit comments

Comments
 (0)