diff --git a/src/components/BuisnessHours/BusinessHourType.ts b/src/components/BuisnessHours/BusinessHourType.ts new file mode 100644 index 00000000..1c82623d --- /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 00000000..973db22f --- /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 00000000..5ef0869e --- /dev/null +++ b/src/components/BuisnessHours/MucBusinessHours.vue @@ -0,0 +1,166 @@ + + + + +