From 628bc8f71cfa35b363aa605f29524ed17dd30760 Mon Sep 17 00:00:00 2001 From: gabrielRochaBuilders <167531818+gabrielRochaBuilders@users.noreply.github.com> Date: Thu, 29 Aug 2024 09:44:46 -0300 Subject: [PATCH] adjust components `datePicker` and `select` (#184) * adjust components `datePicker` and `select` * adjust types this component `select` --- documentation/sidebars.js | 1 + package.json | 2 +- .../DatePicker/DatePicker.stories.tsx | 6 ++--- src/components/DatePicker/index.tsx | 3 +++ src/components/Select/index.tsx | 26 ++++++++++++++----- src/components/Select/select.stories.tsx | 3 +++ 6 files changed, 31 insertions(+), 10 deletions(-) diff --git a/documentation/sidebars.js b/documentation/sidebars.js index 8286e162..b0ba3454 100644 --- a/documentation/sidebars.js +++ b/documentation/sidebars.js @@ -28,6 +28,7 @@ module.exports = { 'component.paper', 'component.Select', 'component.textInput', + 'component.datePicker', { Typography: [ 'component.typography', diff --git a/package.json b/package.json index fca4afd7..6494a86d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@platformbuilders/fluid-react", - "version": "1.2.6", + "version": "1.2.7", "private": false, "description": "Builders React for Fluid Design System", "keywords": [ diff --git a/src/components/DatePicker/DatePicker.stories.tsx b/src/components/DatePicker/DatePicker.stories.tsx index 130a8c27..16d44dce 100644 --- a/src/components/DatePicker/DatePicker.stories.tsx +++ b/src/components/DatePicker/DatePicker.stories.tsx @@ -1,6 +1,6 @@ -import { expect, jest } from '@storybook/jest'; +import { jest } from '@storybook/jest'; import type { Meta, StoryObj } from '@storybook/react'; -import { configure, userEvent, within } from '@storybook/testing-library'; +import { configure } from '@storybook/testing-library'; import DatePicker from './index'; configure({ @@ -9,7 +9,6 @@ configure({ // Mocks const onChange = jest.fn(); -const calendarTestID = 'calendar-test-id'; const meta: Meta = { title: 'Components/DatePicker', @@ -26,6 +25,7 @@ const meta: Meta = { workDays: { control: { type: 'boolean' } }, minDate: { control: { type: 'boolean' } }, maxDate: { control: { type: 'boolean' } }, + inputVariant: { type: 'string' }, }, args: { onChange: onChange, diff --git a/src/components/DatePicker/index.tsx b/src/components/DatePicker/index.tsx index 8ef2262f..59062ff7 100644 --- a/src/components/DatePicker/index.tsx +++ b/src/components/DatePicker/index.tsx @@ -15,6 +15,7 @@ interface Props extends DatePickerProps { disableYearPicker?: boolean; workDays?: boolean; holidays?: string[]; + inputVariant?: 'default' | 'outlined'; } const DatePickerComponent: React.FC = ({ @@ -28,6 +29,7 @@ const DatePickerComponent: React.FC = ({ holidays, name, id, + inputVariant = 'outlined', }) => { const datePickerRef = useRef(); return ( @@ -43,6 +45,7 @@ const DatePickerComponent: React.FC = ({ onClick={openCalendar} onChange={(e) => onChange(e)} iconRight="ChevronDownIcon" + variant={inputVariant} /> ); }} diff --git a/src/components/Select/index.tsx b/src/components/Select/index.tsx index 33e98dae..01b0a89f 100644 --- a/src/components/Select/index.tsx +++ b/src/components/Select/index.tsx @@ -1,9 +1,12 @@ -import { FC } from 'react'; +import { FC, SelectHTMLAttributes } from 'react'; import { ChevronDownIcon, ChevronUpIcon } from '@radix-ui/react-icons'; import { Icon, ScrollDownButton, ScrollUpButton, + SelectItemProps, + SelectTriggerProps, + SelectViewportProps, Value, } from '@radix-ui/react-select'; import { @@ -21,7 +24,7 @@ type SelectOptions = { value: string; }; -type Props = { +export type SelectProps = SelectHTMLAttributes & { id: string; options: SelectOptions[]; disabled?: boolean; @@ -31,9 +34,12 @@ type Props = { onValueChange: (value: string) => void; defaultValue?: string; value?: string; + style?: SelectTriggerProps; + styleItem?: SelectItemProps; + styleContentItem?: SelectViewportProps; }; -const Select: FC = ({ +const Select: FC = ({ options, disabled = false, placeholder, @@ -41,13 +47,21 @@ const Select: FC = ({ value, defaultValue, id, + style, + styleItem, + styleContentItem, }) => ( - + {placeholder}} /> @@ -57,9 +71,9 @@ const Select: FC = ({ - + {options.map((item) => ( - + {item.option} ))} diff --git a/src/components/Select/select.stories.tsx b/src/components/Select/select.stories.tsx index 58375c84..d14be182 100644 --- a/src/components/Select/select.stories.tsx +++ b/src/components/Select/select.stories.tsx @@ -21,6 +21,9 @@ const meta: Meta = { helperMessage: 'Select Test', label: 'Select Test', value: 'Female', + style: {}, + styleContentItem: {}, + styleItem: undefined, options: [ { value: 'Male',