Skip to content

Commit

Permalink
Code Review: refactor CSS classes to kebab-case
Browse files Browse the repository at this point in the history
  • Loading branch information
nighto committed Dec 13, 2024
1 parent b248aa0 commit 7d63e83
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -184,20 +184,20 @@ $navigation-distance: 1rem;
@layer baklava.components {
$caret-width: 18px;

.bk-datepicker {
@include bk.component-base(bk-datepicker);
.bk-date-picker {
@include bk.component-base(bk-date-picker);
display: flex;
flex-direction: row;
align-items: center;
margin-right: -$caret-width;
}

.bk-datepicker--input {
.bk-date-picker--input {
width: 121px;
color: bk.$theme-form-text-default;
}

.bk-datepicker--caret {
.bk-date-picker--caret {
width: $caret-width;
height: $caret-width;
position: relative;
Expand Down
6 changes: 3 additions & 3 deletions src/components/forms/controls/DatePicker/DatePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const DatePicker = (props: DatePickerProps) => {
return (
<div className={cx(
'bk',
{ [cl['bk-datepicker']]: !unstyled },
{ [cl['bk-date-picker']]: !unstyled },
className,
)}>
<ReactDatePicker
Expand All @@ -54,14 +54,14 @@ export const DatePicker = (props: DatePickerProps) => {
icon={<Icon icon="calendar"/>}
customInput={
<Input className={cx(
{ [cl['bk-datepicker--input']]: !unstyled },
{ [cl['bk-date-picker--input']]: !unstyled },
)}/>
}
onCalendarClose={() => setIsOpen(false)}
onCalendarOpen={() => setIsOpen(true)}
{...propsRest}
/>
<Icon icon={`caret-${isOpen ? 'up' : 'down'}`} className={cx(cl['bk-datepicker--caret'])}/>
<Icon icon={`caret-${isOpen ? 'up' : 'down'}`} className={cx(cl['bk-date-picker--caret'])}/>
</div>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const DatePickerRange = (props: DatePickerRangeProps) => {
return (
<div className={cx(
'bk',
{ [cl['bk-datepicker']]: !unstyled },
{ [cl['bk-date-picker']]: !unstyled },
className,
)}>
<ReactDatePicker
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
@use '../../../../styling/defs.scss' as bk;

@layer baklava.components {
.bk-datetimepicker {
@include bk.component-base(bk-datetimepicker);
.bk-date-time-picker {
@include bk.component-base(bk-date-time-picker);

display: flex;
flex-direction: row;
gap: bk.$spacing-3;
}

.bk-datetimepicker--timepicker {
.bk-date-time-picker--time-picker {
position: relative;
top: 4px;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ type GenericProps = {
export type DateTimePickerProps = GenericProps;

export const DateTimePicker = ({ unstyled = false, className, date, onChange, ...propsRest }: DateTimePickerProps) => {
// time from date object
// Time from date object.
const time = { hours: date?.getHours() || 0, minutes: date?.getMinutes() || 0 };

// manually update upstream date object when time is updated
// Manually update upstream Date object when time is updated.
const onTimeUpdate = (time: Time) => {
if (date) {
const newDate = new Date(date);
Expand All @@ -45,7 +45,7 @@ export const DateTimePicker = ({ unstyled = false, className, date, onChange, ..
return (
<div className={cx(
'bk',
{ [cl['bk-datetimepicker']]: !unstyled },
{ [cl['bk-date-time-picker']]: !unstyled },
className,
)}>
<DatePicker
Expand All @@ -56,7 +56,7 @@ export const DateTimePicker = ({ unstyled = false, className, date, onChange, ..
time={time}
onUpdate={onTimeUpdate}
className={cx(
{ [cl['bk-datetimepicker--timepicker']]: !unstyled },
{ [cl['bk-date-time-picker--time-picker']]: !unstyled },
)}
/>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
@use '../../../../styling/defs.scss' as bk;

@layer baklava.components {
.bk-timepicker {
@include bk.component-base(bk-timepicker);
.bk-time-picker {
@include bk.component-base(bk-time-picker);
line-height: 1.8;
}

.bk-timepicker--input {
.bk-time-picker--input {
color: bk.$theme-form-text-default;
// a manual size increase to accomodate the clock icon without clipping the text
// A manual size increase to accommodate the clock icon without clipping the text.
width: 92px;
}
}
6 changes: 3 additions & 3 deletions src/components/forms/controls/TimePicker/TimePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import cl from './TimePicker.module.scss';
export type Time = {
hours: number,
minutes: number,
}
};

export type TimePickerProps = ComponentProps<'input'> & {
/** Whether this component should be unstyled. */
Expand Down Expand Up @@ -42,15 +42,15 @@ export const TimePicker = ({ unstyled = false, className, time, onUpdate, ...pro
return (
<div className={cx(
'bk',
{ [cl['bk-timepicker']]: !unstyled },
{ [cl['bk-time-picker']]: !unstyled },
className,
)}>
<Input
type="time"
value={timeString}
onChange={onChange}
className={cx(
{ [cl['bk-timepicker--input']]: !unstyled },
{ [cl['bk-time-picker--input']]: !unstyled },
)}
{...propsRest}
/>
Expand Down

0 comments on commit 7d63e83

Please sign in to comment.