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: Add timepicker component #299

Open
wants to merge 65 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 58 commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
7c87efd
custom components
maxxyouu Nov 17, 2023
61655a6
Restore export modal tab order between opens
zvonimirfras Nov 17, 2023
180fa74
Centralize linting rules in root (#291)
Akshat55 Nov 17, 2023
11e53cd
Support {{children}} in custom components
zvonimirfras Nov 23, 2023
9c2984b
Fix export template not working when items empty
zvonimirfras Nov 30, 2023
debbadf
fix: add workflow to release package (#292)
Akshat55 Dec 1, 2023
e080e1d
fix: remove nx set sha action (#293)
Akshat55 Dec 1, 2023
ea419ca
fix: add release config (#294)
Akshat55 Dec 1, 2023
6eeac0a
fix: add permission for id-token (#295)
Akshat55 Dec 1, 2023
8728221
fix: add repository url to packages (#296)
Akshat55 Dec 1, 2023
4a72a08
Add instructions to set up a new project w/ player
zvonimirfras Dec 2, 2023
d7523d3
Fix export error when custom collections undefined
zvonimirfras Dec 4, 2023
6fc2a14
Fix export error when custom collections undefined
zvonimirfras Dec 4, 2023
5200b0c
draft
maxxyouu Jan 24, 2024
300f3bd
draft
maxxyouu Jan 24, 2024
5ff39dd
svg timepicker
maxxyouu Jan 24, 2024
69a994f
timpicker
maxxyouu Jan 25, 2024
9d30222
conflict
maxxyouu Feb 1, 2024
83e7732
progress
maxxyouu Feb 15, 2024
1860d51
double quote to singlel quote
maxxyouu Feb 15, 2024
68087b2
double quote to singlel quote
maxxyouu Feb 15, 2024
f915cd8
slots
maxxyouu Feb 15, 2024
f32c890
build error
maxxyouu Feb 15, 2024
314db02
delete custom compo
maxxyouu Feb 22, 2024
d738613
Update sdk/react/src/lib/fragment-components/a-time-picker.tsx
maxxyouu Feb 22, 2024
ad8bd29
Update sdk/react/src/lib/fragment-components/a-time-picker.tsx
maxxyouu Feb 22, 2024
c8a653e
fix
maxxyouu Feb 22, 2024
4b67bee
Merge branch 'timepicker' of https://github.com/maxxyouu/carbon-ui-bu…
maxxyouu Feb 22, 2024
99e7581
Update sdk/react/src/lib/fragment-components/a-time-picker.tsx
maxxyouu Feb 22, 2024
22df52c
fix
maxxyouu Feb 22, 2024
94aaf53
Merge branch 'timepicker' of https://github.com/maxxyouu/carbon-ui-bu…
maxxyouu Feb 22, 2024
056f1ad
label
maxxyouu Feb 22, 2024
ba39e73
s[ace
maxxyouu Feb 22, 2024
dd82d28
Merge branch 'main' into timepicker
Akshat55 Feb 29, 2024
04b0170
export fix
Mar 1, 2024
b7c03c5
Update sdk/react/src/lib/fragment-components/a-time-picker.tsx
maxxyouu Mar 6, 2024
0e744d1
Update sdk/react/src/lib/fragment-components/a-time-picker.tsx
maxxyouu Mar 6, 2024
7196d40
Update sdk/react/src/lib/fragment-components/a-time-picker.tsx
maxxyouu Mar 6, 2024
593bf51
Update sdk/react/src/lib/fragment-components/a-time-picker.tsx
maxxyouu Mar 6, 2024
0d8150d
pr revision
Mar 6, 2024
52be878
make am/pm and timezone optional
Mar 22, 2024
bb9d0df
make am/pm and timezone optional
Mar 22, 2024
3010c06
done
Mar 27, 2024
446c530
fix export
Apr 25, 2024
26dc9c2
fix action
Apr 25, 2024
c2d1736
Merge branch 'main' of https://github.com/IBM/carbon-ui-builder into …
May 3, 2024
86864e5
lint
May 3, 2024
666b1bb
chore: lint fix
Akshat55 May 10, 2024
54bcf0a
chore: lint exports
Akshat55 May 10, 2024
56c4a16
fix: remove redundant attribute from interface
Akshat55 May 10, 2024
286b536
fix: correct export conditions
Akshat55 May 10, 2024
3000eb1
fix: add missing events in export
Akshat55 May 16, 2024
da19cbd
fixed angular export
May 29, 2024
528347f
angular export
May 29, 2024
8793f16
resolve conflict
May 29, 2024
9bf08e3
angular export fix
May 29, 2024
cb7d011
fix react export import section
May 29, 2024
d906675
Merge branch 'main' into timepicker
Akshat55 May 29, 2024
b0608e3
Update player/react/src/lib/components/ui-time-picker.tsx
maxxyouu Jul 22, 2024
3378c01
Update player/react/src/lib/components/ui-time-picker.tsx
maxxyouu Jul 22, 2024
6bf50b8
Update sdk/react/src/lib/fragment-components/a-time-picker.tsx
maxxyouu Jul 22, 2024
50e59e1
revision
Jul 22, 2024
fe4c0fe
revision
Jul 22, 2024
d605326
revision
Jul 22, 2024
0d89669
style
Jul 24, 2024
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
2 changes: 2 additions & 0 deletions player/react/src/lib/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import * as searchinput from './ui-search-input';
import * as text from './ui-text';
import * as textarea from './ui-text-area';
import * as textinput from './ui-text-input';
import * as timepicker from './ui-time-picker';
import * as link from './ui-link';
import * as loading from './ui-loading';
import * as inlineLoading from './ui-inline-loading';
Expand Down Expand Up @@ -59,6 +60,7 @@ export const allComponents = {
text,
textarea,
textinput,
timepicker,
overflowMenu,
// Tiles
tile,
Expand Down
119 changes: 119 additions & 0 deletions player/react/src/lib/components/ui-time-picker.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
import React from 'react';
import { TimePickerSelect, TimePicker, SelectItem } from '@carbon/react';
import { commonSlots, slotsDisabled } from '../common-slots';
import { SendSignal } from '../types';

export interface TimePickerState {
id: string | number;
codeContext?: {
name: string;
};
type: string;
placeholder: string;
disabled?: boolean;
invalid?: boolean;
invalidText?: string;
light?: boolean;
size?: string;
value?: string;
label?: string;
timezones?: [];
showTimePeriod?: boolean;
maxxyouu marked this conversation as resolved.
Show resolved Hide resolved
timePeriod?: [];
}

export const type = 'time-picker';

export const signals = ['valueChange', 'click', 'timezoneValueChange', 'timePeriodValueChange'];

export const slots = {
...commonSlots,
...slotsDisabled,
invalid: 'boolean',
isInvalid: (state: TimePickerState) => ({
Copy link
Member

@zvonimirfras zvonimirfras Jul 16, 2024

Choose a reason for hiding this comment

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

They should be setters and follow function naming e.g. setInvalid
Plus, setInvalid seems like it would do the same thing as invalid property, so it's not necessary?

note: date picker seems to be doing the naming right

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i think the naming of the setter is fine, i don't think other component (i,e. combobox) use this naming. setInvalid is fine but no need for unnecessary changes.

In terms of the need of setInvalid, please check combobox as well because the setter is similar.

...state,
invalid: true
}),
isValid: (state: TimePickerState) => ({
...state,
invalid: false
}),
toggleIsInvalid: (state: TimePickerState) => ({
...state,
invalid: !state.invalid
}),
light: 'boolean',
isLight: (state: TimePickerState) => ({
...state,
light: true
}),
isDark: (state: TimePickerState) => ({
...state,
light: false
}),
toggleIsLight: (state: TimePickerState) => ({
...state,
light: !state.light
}),
placeholder: 'string',
type: 'string',
invalidText: 'string',
label: 'string',
size: 'string',
value: 'string'
};

export const UITimePicker = ({ state, sendSignal }: {
state: TimePickerState;
setState: (state: any) => void;
setGlobalState: (state: any) => void;
sendSignal: SendSignal;
}) => {
if (state.type !== 'time-picker') {
// eslint-disable-next-line react/jsx-no-useless-fragment
return <></>;
}

return <TimePicker
id={state.codeContext?.name}
light={state.light}
disabled={state.disabled}
invalid={state.invalid}
invalidText={state.invalidText}
placeholder={state.placeholder}
size={state.size}
labelText={state.label}
onClick={() => {
sendSignal(state.id, 'click');
}}
onChange={(event: any) => {
sendSignal(state.id, 'valueChange', [event.value], { ...state, value: event.value });
}}>
{state.showTimePeriod &&
<TimePickerSelect
id={state.codeContext?.name + '-select-1'}
maxxyouu marked this conversation as resolved.
Show resolved Hide resolved
onChange={(event: any) => {
sendSignal(state.id, 'timePeriodValueChange', [event.value], { ...state, value: event.value });
}}>
<SelectItem value='AM' text='AM' />
<SelectItem value='PM' text='PM' />
</TimePickerSelect>
}
{state.timezones?.length &&
<TimePickerSelect
id={state.codeContext?.name + '-select-2'}
maxxyouu marked this conversation as resolved.
Show resolved Hide resolved
onChange={(event: any) => {
sendSignal(state.id, 'timezoneValueChange', [event.value], { ...state, value: event.value });
}}>
{
state.timezones.map((step: any, index: number) => <SelectItem
value={step.value}
text={step.text}
selected={step.selected}
key={index}
/>)
}
</TimePickerSelect>
}
</TimePicker>;
};
4 changes: 4 additions & 0 deletions player/react/src/lib/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import { UITextAreaInput } from './components/ui-text-area';
import { UITextInput } from './components/ui-text-input';
import { UITile } from './components/ui-tile';
import { UITileFold } from './components/ui-tile-fold';
import { UITimePicker } from './components/ui-time-picker';
import { UIToggle } from './components/ui-toggle';
import { kebabCase } from 'lodash';
import { SendSignal } from './types';
Expand Down Expand Up @@ -283,6 +284,9 @@ export const renderComponents = (
case 'text-input':
return <UITextInput key={state.id} state={state} sendSignal={sendSignal} setState={setState} setGlobalState={setGlobalState} />;

case 'time-picker':
return <UITimePicker key={state.id} state={state} sendSignal={sendSignal} setState={setState} setGlobalState={setGlobalState} />;

case 'overflow-menu':
return <UIOverflowMenu key={state.id} state={state} sendSignal={sendSignal} setState={setState} setGlobalState={setGlobalState} />;

Expand Down
7 changes: 7 additions & 0 deletions sdk/react/src/lib/assets/component-icons/time-picker.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading