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(vara-ui): upd select #1696

Open
wants to merge 1 commit into
base: main
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
5 changes: 5 additions & 0 deletions utils/vara-ui/src/components/select/helpers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const selectSizes = ['default', 'medium', 'small'] as const;
type ISelectSizes = (typeof selectSizes)[number];

export { selectSizes };
export type { ISelectSizes };
157 changes: 127 additions & 30 deletions utils/vara-ui/src/components/select/select.module.scss
Original file line number Diff line number Diff line change
@@ -1,31 +1,32 @@
.root {
&.disabled {
pointer-events: none;
opacity: 0.3;
}
}
cursor: not-allowed;

.base {
position: relative;
}
* {
pointer-events: none;
}

.select,
.label {
font-size: 16px;
font-weight: 400;
line-height: 24px;
letter-spacing: 0.009em;
color: #010500;
.fieldset {
background-color: #eceded;
border-color: #d0d5dd;
}

&.default {
font-size: 16px;
}
.select:disabled {
cursor: not-allowed;
}

&.small {
font-size: 14px;
.select,
.label {
color: #58696e80;
}
}
}

.base {
position: relative;
user-select: none;
}

.select {
appearance: none;
background-color: transparent;
Expand All @@ -36,7 +37,7 @@

width: 100%;
padding: 8px 14px;
background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M4.616 5.54a.5.5 0 0 0 .768 0L9.317.82A.5.5 0 0 0 8.932 0H1.068a.5.5 0 0 0-.385.82l3.933 4.72Z' fill='%230C0C0D' fill-opacity='.5'/%3E%3C/svg%3E");
background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M4.616 5.54a.5.5 0 0 0 .768 0L9.317.82A.5.5 0 0 0 8.932 0H1.068a.5.5 0 0 0-.385.82l3.933 4.72Z' fill='%2358696E'/%3E%3C/svg%3E");
background-position: right 14px center;
background-repeat: no-repeat;

Expand All @@ -58,32 +59,37 @@

&:focus {
~ .fieldset {
border-color: #00b387;
border-color: #53eece;

.legendLabel {
color: #00b387;
color: #53eece;
}
}
}

&.error {
~ .fieldset {
border-color: #fc174d;
border-color: #ff3231cc;

.legendLabel {
color: #fc174d;
color: #ff3231cc;
}
}
}

&.default {
padding-top: 13px;
padding-bottom: 13px;
padding-top: 14px;
padding-bottom: 14px;
}

&.medium {
padding-top: 9px;
padding-bottom: 9px;
}

&.small {
padding-top: 8px;
padding-bottom: 8px;
padding-top: 6px;
padding-bottom: 6px;
}
}

Expand All @@ -95,6 +101,26 @@
left: 13px;
}

.select,
.label {
font-weight: 400;
line-height: 24px;
color: #000000;

&.default {
font-size: 16px;
}

&.medium {
font-size: 16px;
}

&.small {
font-size: 14px;
line-height: 20px;
}
}

.fieldset {
min-width: 0;
margin: 0;
Expand All @@ -107,17 +133,19 @@
bottom: 0;
left: 0;
right: 0;
z-index: -1;

border: 1px solid #0000003b;
border-radius: 4px;
background-color: #ffffff;
border: 1px solid #d0d5dd;
box-shadow: 0 1px 2px 0 #1018280d;
}

.legend,
.message {
font-size: 12px;
font-weight: 400;
line-height: 1;
letter-spacing: 0.01em;
}

.legend {
Expand All @@ -138,3 +166,72 @@
.block {
width: 100%;
}

:global(.dark-theme) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like we need styles for options in dark-theme
image

.root {
&.disabled {
.fieldset {
background-color: #282c301a;
border-color: #ffffff0a;
}

.input,
.label {
color: #9cacb166;
}
}
}

.fieldset {
background-color: transparent;
border: 1px solid rgba(255, 255, 255, 0.04);
box-shadow: 0 1px 2px 0 #1018280d;
}

.label,
.select {
color: #828b8e;
}

.select {
color: #f6f6f6e5;
background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M4.616 5.54a.5.5 0 0 0 .768 0L9.317.82A.5.5 0 0 0 8.932 0H1.068a.5.5 0 0 0-.385.82l3.933 4.72Z' fill='%23828B8E'/%3E%3C/svg%3E");


&:focus::placeholder {
color: #828b8e;
}

&:focus {
~ .fieldset {
border-color: #0fa885;

.legendLabel {
color: #0fa885;
}
}
}

&.error {
~ .label {
color: #d73b4f;
}

~ .fieldset {
border-color: #d73b4f;

.legendLabel {
color: #d73b4f;
}
}
}

.message {
color: #d73b4f;
}
}

.legend {
color: #828b8e;
}
}
13 changes: 13 additions & 0 deletions utils/vara-ui/src/components/select/select.stories.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Meta, StoryObj } from '@storybook/react';
import { Select } from './select';
import { selectSizes } from './helpers';

type Type = typeof Select;
type Story = StoryObj<Type>;
Expand All @@ -13,6 +14,18 @@ const meta: Meta<Type> = {
{ label: 'Option 2', value: 'option-2' },
{ label: 'Option 3', value: 'option-3' },
],
label: '',
size: 'default',
disabled: false,
block: false,
},
argTypes: {
disabled: { control: 'boolean' },
block: { control: 'boolean' },
size: {
options: selectSizes,
control: { type: 'select' },
},
},
};

Expand Down
10 changes: 8 additions & 2 deletions utils/vara-ui/src/components/select/select.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { SelectHTMLAttributes, OptionHTMLAttributes, ReactNode, useId, forwardRef } from 'react';
import cx from 'clsx';
import styles from './select.module.scss';
import type { ISelectSizes } from './helpers.ts';

type Props = Omit<SelectHTMLAttributes<HTMLSelectElement>, 'id' | 'size'> & {
options: OptionHTMLAttributes<HTMLOptionElement>[] | Readonly<OptionHTMLAttributes<HTMLOptionElement>[]>;
size?: 'default' | 'small';
size?: ISelectSizes;
label?: string;
error?: ReactNode;
block?: boolean;
Expand All @@ -21,7 +22,12 @@ const Select = forwardRef<HTMLSelectElement, Props>(
return (
<div className={cx(styles.root, className, disabled && styles.disabled, block && styles.block)}>
<div className={styles.base}>
<select id={id} className={cx(styles.select, styles[size], error && styles.error)} ref={ref} {...attrs}>
<select
id={id}
className={cx(styles.select, styles[size], error && styles.error)}
ref={ref}
disabled={disabled}
{...attrs}>
{getOptions()}
</select>

Expand Down
Loading