Skip to content

Commit

Permalink
feat: variant & disabled styles
Browse files Browse the repository at this point in the history
  • Loading branch information
timoheddes committed Aug 23, 2023
1 parent 14ec3b3 commit 73182c9
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
18 changes: 15 additions & 3 deletions packages/libs/react-ui/src/components/Select/Select.css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,32 @@ export const containerClass = style([
},
}),
{
// border: `1px solid`,
position: 'relative',
},
]);

export const containerClassDisabled = style([
sprinkles({
backgroundColor: {
lightMode: '$gray30',
// darkMode: '$gray100',
},
color: {
lightMode: '$gray100',
// darkMode: '$gray40',
},
}),
]);

export const selectVariants = styleVariants({
default: [
{
borderBottom: `1px solid ${vars.colors.$gray30}`,
},
],
form: [
solid: [
{
borderBottom: `1px solid ${vars.colors.$gray30}`,
border: `1px solid ${vars.colors.$gray30}`,
},
],
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Option } from './Option';
import { ISelectProps, Select } from './Select';
import { ISelectProps, Select, variants } from './Select';

import { SystemIcon } from '@components/Icon';
import type { Meta, StoryObj } from '@storybook/react';
Expand Down Expand Up @@ -32,7 +32,7 @@ const meta: Meta<
type: { summary: 'select' },
defaultValue: { summary: 'default' },
},
options: ['default', 'form'],
options: variants,
},
icon: {
options: [
Expand Down
11 changes: 9 additions & 2 deletions packages/libs/react-ui/src/components/Select/Select.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
containerClass,
containerClassDisabled,
iconClass,
selectClass,
selectContainerClass,
Expand All @@ -10,6 +11,8 @@ import { SystemIcon } from '@components/Icon';
import classNames from 'classnames';
import React, { FC, forwardRef } from 'react';

export const variants: ['default', 'solid'] = ['default', 'solid'];

export interface ISelectProps
extends Omit<
React.HTMLAttributes<HTMLSelectElement>,
Expand All @@ -22,7 +25,7 @@ export interface ISelectProps
onChange: React.ChangeEventHandler<HTMLSelectElement>;
ref?: React.ForwardedRef<HTMLSelectElement>;
ariaLabel: string;
variant?: 'default' | 'form';
variant?: (typeof variants)[number];
}

export const Select: FC<ISelectProps> = forwardRef<
Expand All @@ -42,7 +45,11 @@ export const Select: FC<ISelectProps> = forwardRef<
) {
return (
<div
className={classNames(containerClass, selectVariants[variant])}
className={classNames(
containerClass,
selectVariants[variant],
disabled && containerClassDisabled,
)}
data-testid="kda-select"
>
<label>
Expand Down

0 comments on commit 73182c9

Please sign in to comment.