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

IT-5863 tile and datepickers with boarders #447

Merged
merged 11 commits into from
Dec 5, 2024
2 changes: 2 additions & 0 deletions lib/js/components/DatePickers/DatePicker/DatePicker.consts.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { Value } from '../../../utils/type.utils';

export const DATE_PICKER_COLORS = {
NEUTRAL_WEAK: 'neutralWeak',
NEUTRAL: 'neutral',
WARNING: 'warning',
DANGER: 'danger',
};

export type DatePickerColors = Value<typeof DATE_PICKER_COLORS>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ const StoryTemplate: StoryFn<typeof DatePicker> = (args) => {
:is-interactive="isInteractive"
:placeholder="placeholder"
:date="formattedDate"
:additional-text="additionalText"
:label="label"
:is-label-uppercase="isLabelUppercase"
:icon="icon ? ICONS[icon] : null"
Expand All @@ -93,14 +94,15 @@ const args = {
isInteractive: true,
placeholder: 'Wybierz datę',
date: '',
additionalText: '',
label: 'Date picker',
isLabelUppercase: false,
icon: 'FA_CALENDAR_DAY',
isIconHiddenOnMobile: false,
calendarPosition: DATE_PICKER_CALENDAR_POSITIONS.BOTTOM,
errorMessage: null,
state: DATE_PICKER_STATES.DEFAULT,
color: DATE_PICKER_COLORS.NEUTRAL,
color: DATE_PICKER_COLORS.NEUTRAL_WEAK,
disableDates: [new Date(now + oneDayMili * 2).toISOString().slice(0, 10)],
minDate: new Date(now).toISOString().slice(0, 10),
maxDate: new Date(now + oneDayMili * 30).toISOString().slice(0, 10),
Expand Down
11 changes: 10 additions & 1 deletion lib/js/components/DatePickers/DatePicker/DatePicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@
class="ds-datePicker__tile"
:text="text"
:interactive="isInteractive"
:additional-text="additionalText"
:color="color as TileColors"
:state="state as TileStates"
:icon-right="tileIcon"
:is-icon-right-hidden-on-mobile="isIconHiddenOnMobile"
:eyebrow-text="eyebrowText"
has-border
@click="toggle"
/>
</template>
Expand Down Expand Up @@ -167,6 +169,10 @@ export default defineComponent({
type: Date,
default: null,
},
additionalText: {
type: String,
default: '',
},
label: {
type: String,
default: '',
Expand Down Expand Up @@ -196,7 +202,7 @@ export default defineComponent({
},
color: {
type: String as PropType<DatePickerColors>,
default: DATE_PICKER_COLORS.NEUTRAL,
default: DATE_PICKER_COLORS.NEUTRAL_WEAK,
},
calendarPosition: {
type: String as PropType<DatePickerCalendarPositions>,
Expand Down Expand Up @@ -275,6 +281,9 @@ export default defineComponent({
return localFullDateWithShortMonthName(this.date);
},
tileIcon() {
if (this.additionalText) {
return null;
}
if (!this.icon) {
return null;
}
Expand Down
24 changes: 21 additions & 3 deletions lib/js/components/DatePickers/DatePickerBox/DatePickerBox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
'-ds-loading': state === DATE_PICKER_STATES.LOADING,
'-ds-interactive': isInteractive,
'-ds-warning': color === DATE_PICKER_COLORS.WARNING,
'-ds-neutral': color === DATE_PICKER_COLORS.NEUTRAL,
'-ds-neutralWeak': [
DATE_PICKER_COLORS.NEUTRAL_WEAK,
DATE_PICKER_COLORS.NEUTRAL,
].includes(color),
'-ds-danger': color === DATE_PICKER_COLORS.DANGER,
'-ds-isOpen': isOpen,
}"
>
Expand Down Expand Up @@ -244,7 +248,7 @@
}

&.-ds-loading,
&.-ds-neutral {
&.-ds-neutralWeak {
@include color-scheme(
$color-neutral-text-weak,
$color-neutral-text-heavy,
Expand Down Expand Up @@ -283,6 +287,20 @@
$self
);
}

&.-ds-danger {
@include color-scheme(
$color-danger-text,
$color-danger-text,
$color-danger-icon,
$color-danger-icon-hovered,
$color-danger-text-hovered,
$color-danger-icon-disabled,
$color-danger-text-disabled,
$color-danger-text-disabled,
$self
);
}
}
}
</style>
Expand Down Expand Up @@ -340,7 +358,7 @@ export default defineComponent({
},
color: {
type: String as PropType<DatePickerColors>,
default: DATE_PICKER_COLORS.NEUTRAL,
default: DATE_PICKER_COLORS.NEUTRAL_WEAK,
},
startDateEyebrowText: {
type: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,9 @@ const meta: Meta<DateRangePickerProps> = {
},
color: {
control: 'select',
options: Object.values(DATE_PICKER_COLORS),
options: Object.values(DATE_PICKER_COLORS).filter(
(color) => color !== DATE_PICKER_COLORS.NEUTRAL,
),
},
disableDates: {
control: 'object',
Expand Down Expand Up @@ -144,7 +146,7 @@ export const Interactive: Story = {
calendarPosition: DATE_PICKER_CALENDAR_POSITIONS.BOTTOM,
errorMessage: '',
state: DATE_PICKER_STATES.DEFAULT,
color: DATE_PICKER_COLORS.NEUTRAL,
color: DATE_PICKER_COLORS.NEUTRAL_WEAK,
disableDates: [new Date(now + oneDayMili * 2).toISOString().slice(0, 10)],
minDate: new Date(now).toISOString().slice(0, 10),
maxDate: new Date(now + oneDayMili * 30).toISOString().slice(0, 10),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export default defineComponent({
},
color: {
type: String as PropType<DatePickerColors>,
default: DATE_PICKER_COLORS.NEUTRAL,
default: DATE_PICKER_COLORS.NEUTRAL_WEAK,
},
disableDates: {
type: Array as PropType<Array<Date>>,
Expand Down
4 changes: 1 addition & 3 deletions lib/js/components/Drawer/DrawerTile/DrawerTile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ export default defineComponent({
},
// Only allow props that are supported by Tile
props,
// TODO fix me when touching this file
// eslint-disable-next-line vue/require-emit-validator
emits: ['click'],
emits: { click: () => true },
});
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
:state="state"
:eyebrow-ellipsis="eyebrowEllipsis"
:text-ellipsis="textEllipsis"
:has-border="hasBorder"
/>
</div>
</template>
Expand Down
1 change: 1 addition & 0 deletions lib/js/components/Tile/Tile.consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export const TILE_COLORS = {
PRIMARY: 'primary',
SUCCESS: 'success',
FAIL: 'fail',
DANGER: 'danger',
WARNING: 'warning',
INFO: 'info',
} as const;
Expand Down
2 changes: 2 additions & 0 deletions lib/js/components/Tile/Tile.sb.shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const template = (componentTag: string) => `
:state="state"
:text-ellipsis="textEllipsis"
:text="text"
:has-border="hasBorder"
/>`;

export const data = () => ({
Expand All @@ -35,6 +36,7 @@ export const args = {
eyebrowEllipsis: true,
textEllipsis: true,
color: TILE_COLORS.NEUTRAL,
hasBorder: false,
} as Args;

export const argTypes = {
Expand Down
4 changes: 4 additions & 0 deletions lib/js/components/Tile/Tile.shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,8 @@ export const props = {
type: Boolean,
default: true,
},
hasBorder: {
type: Boolean,
default: false,
},
};
Loading