From 97ceb3c4e9c2a2be11089d4e2bfa63dc8bdead80 Mon Sep 17 00:00:00 2001 From: langehm <38280183+langehm@users.noreply.github.com> Date: Tue, 28 May 2024 10:49:44 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=2041=20sparkles=20adding=20business?= =?UTF-8?q?=20hours=20component=20(#93)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BuisnessHours/BusinessHourType.ts | 28 +++ .../BuisnessHours/BusinessHours.stories.ts | 108 ++++++++++++ .../BuisnessHours/MucBusinessHours.vue | 166 ++++++++++++++++++ 3 files changed, 302 insertions(+) create mode 100644 src/components/BuisnessHours/BusinessHourType.ts create mode 100644 src/components/BuisnessHours/BusinessHours.stories.ts create mode 100644 src/components/BuisnessHours/MucBusinessHours.vue diff --git a/src/components/BuisnessHours/BusinessHourType.ts b/src/components/BuisnessHours/BusinessHourType.ts new file mode 100644 index 0000000..1c82623 --- /dev/null +++ b/src/components/BuisnessHours/BusinessHourType.ts @@ -0,0 +1,28 @@ +/** + * Shorthand notation of all seven days in german. + * + * @typedef {"Mo" | "Di" | "Mi" | "Do" | "Fr" | "Sa" | "So"} WeekDays + */ +type WeekDays = "Mo" | "Di" | "Mi" | "Do" | "Fr" | "Sa" | "So"; + +/** + * @typedef {Object} OpeningHour + * @property {string} from - The start time of the opening period (in 'HH:mm' format). + * @property {string} to - The end time of the opening period (in 'HH:mm' format). + */ +type OpeningHour = { + from: string; + to: string; +}; + +/** + * @typedef {Object} BusinessHourType + * @property {WeekDays} weekDay - The day of the week for which the opening hours apply. + * @property {OpeningHour[]} openingHours - A list of opening hours for the specified day of the week. + */ +type BusinessHourType = { + weekDay: WeekDays; + openingHours: OpeningHour[]; +}; + +export type { BusinessHourType, OpeningHour, WeekDays }; diff --git a/src/components/BuisnessHours/BusinessHours.stories.ts b/src/components/BuisnessHours/BusinessHours.stories.ts new file mode 100644 index 0000000..973db22 --- /dev/null +++ b/src/components/BuisnessHours/BusinessHours.stories.ts @@ -0,0 +1,108 @@ +import MucBusinessHours from "./MucBusinessHours.vue"; + +export default { + component: MucBusinessHours, + title: "MucBusinessHours", + tags: ["autodocs"], + // 👇 Use `fn` to spy on the onClick arg, which will appear in the actions panel once invoked + parameters: { + docs: { + description: { + component: ` +The businessHours component is used to display the business hours for each day of the week. +The current day is highlighted as well as the days that are closed. +In the toggleable variant, the current day and the opening hours are also displayed on the toggle button. + +[🔗 Patternlab-Docs](https://patternlab.muenchen.space/?p=viewall-components-business-hours) +`, + }, + }, + }, +}; + +const businessHours = [ + { + weekDay: "Mo", + openingHours: [ + { + from: "08:00", + to: "12:00", + }, + { + from: "14:00", + to: "18:00", + }, + ], + }, + { + weekDay: "Di", + openingHours: [ + { + from: "09:00", + to: "13:00", + }, + ], + }, + { + weekDay: "Mi", + openingHours: [ + { + from: "10:00", + to: "14:00", + }, + ], + }, + { + weekDay: "Do", + openingHours: [ + { + from: "08:00", + to: "12:00", + }, + { + from: "15:00", + to: "19:00", + }, + ], + }, + { + weekDay: "Fr", + openingHours: [ + { + from: "08:00", + to: "12:00", + }, + { + from: "13:00", + to: "17:00", + }, + ], + }, + { + weekDay: "Sa", + openingHours: [ + { + from: "10:00", + to: "13:00", + }, + ], + }, + { + weekDay: "So", + openingHours: [], + }, +]; + +export const Default = { + args: { + businessHours: businessHours, + toggleable: true, + }, +}; + +export const Fixed = { + args: { + ...Default.args, + toggleable: false, + }, +}; diff --git a/src/components/BuisnessHours/MucBusinessHours.vue b/src/components/BuisnessHours/MucBusinessHours.vue new file mode 100644 index 0000000..5ef0869 --- /dev/null +++ b/src/components/BuisnessHours/MucBusinessHours.vue @@ -0,0 +1,166 @@ + + + + +