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

adjust components datePicker and select #184

Merged
merged 2 commits into from
Aug 29, 2024
Merged
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
1 change: 1 addition & 0 deletions documentation/sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ module.exports = {
'component.paper',
'component.Select',
'component.textInput',
'component.datePicker',
{
Typography: [
'component.typography',
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": [
Expand Down
6 changes: 3 additions & 3 deletions src/components/DatePicker/DatePicker.stories.tsx
Original file line number Diff line number Diff line change
@@ -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({
Expand All @@ -9,7 +9,6 @@ configure({

// Mocks
const onChange = jest.fn();
const calendarTestID = 'calendar-test-id';

const meta: Meta<typeof DatePicker> = {
title: 'Components/DatePicker',
Expand All @@ -26,6 +25,7 @@ const meta: Meta<typeof DatePicker> = {
workDays: { control: { type: 'boolean' } },
minDate: { control: { type: 'boolean' } },
maxDate: { control: { type: 'boolean' } },
inputVariant: { type: 'string' },
},
args: {
onChange: onChange,
Expand Down
3 changes: 3 additions & 0 deletions src/components/DatePicker/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ interface Props extends DatePickerProps {
disableYearPicker?: boolean;
workDays?: boolean;
holidays?: string[];
inputVariant?: 'default' | 'outlined';
}

const DatePickerComponent: React.FC<Props> = ({
Expand All @@ -28,6 +29,7 @@ const DatePickerComponent: React.FC<Props> = ({
holidays,
name,
id,
inputVariant = 'outlined',
}) => {
const datePickerRef = useRef();
return (
Expand All @@ -43,6 +45,7 @@ const DatePickerComponent: React.FC<Props> = ({
onClick={openCalendar}
onChange={(e) => onChange(e)}
iconRight="ChevronDownIcon"
variant={inputVariant}
/>
);
}}
Expand Down
26 changes: 20 additions & 6 deletions src/components/Select/index.tsx
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -21,7 +24,7 @@ type SelectOptions = {
value: string;
};

type Props = {
export type SelectProps = SelectHTMLAttributes<HTMLSelectElement> & {
id: string;
options: SelectOptions[];
disabled?: boolean;
Expand All @@ -31,23 +34,34 @@ type Props = {
onValueChange: (value: string) => void;
defaultValue?: string;
value?: string;
style?: SelectTriggerProps;
styleItem?: SelectItemProps;
styleContentItem?: SelectViewportProps;
};

const Select: FC<Props> = ({
const Select: FC<SelectProps> = ({
options,
disabled = false,
placeholder,
onValueChange,
value,
defaultValue,
id,
style,
styleItem,
styleContentItem,
}) => (
<Wrapper
onValueChange={onValueChange}
defaultValue={defaultValue}
value={value}
>
<StyledTrigger id={id} aria-label="select" disabled={disabled}>
<StyledTrigger
id={id}
aria-label="select"
disabled={disabled}
style={style}
>
<Value placeholder={<PlaceholderText>{placeholder}</PlaceholderText>} />
<Icon>
<ChevronDownIcon />
Expand All @@ -57,9 +71,9 @@ const Select: FC<Props> = ({
<ScrollUpButton>
<ChevronUpIcon />
</ScrollUpButton>
<StyledViewPort>
<StyledViewPort style={styleContentItem}>
{options.map((item) => (
<StyledItem value={item.value} key={item.value}>
<StyledItem value={item.value} key={item.value} style={styleItem}>
<StyledItemText>{item.option}</StyledItemText>
</StyledItem>
))}
Expand Down
3 changes: 3 additions & 0 deletions src/components/Select/select.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ const meta: Meta<typeof Select> = {
helperMessage: 'Select Test',
label: 'Select Test',
value: 'Female',
style: {},
styleContentItem: {},
styleItem: undefined,
options: [
{
value: 'Male',
Expand Down
Loading