File tree Expand file tree Collapse file tree 2 files changed +105
-0
lines changed
src/components/BuisnessHours Expand file tree Collapse file tree 2 files changed +105
-0
lines changed Original file line number Diff line number Diff line change
1
+ import MucBusinessHoursTile from "./MucBusinessHoursTile.vue" ;
2
+
3
+ export default {
4
+ component : MucBusinessHoursTile ,
5
+ title : "MucBusinessHoursTile" ,
6
+ tags : [ "autodocs" ] ,
7
+ // 👇 Use `fn` to spy on the onClick arg, which will appear in the actions panel once invoked
8
+ parameters : {
9
+ docs : {
10
+ description : {
11
+ component : `
12
+ The businessHoursTile component is used to display the business hours for each day of the week.
13
+
14
+ [🔗 Patternlab-Docs](https://patternlab.muenchen.space/?p=viewall-components-business-hours)
15
+ ` ,
16
+ } ,
17
+ } ,
18
+ } ,
19
+ } ;
20
+
21
+ const businessHours = {
22
+ weekDay : "Mo" ,
23
+ openingHours : [
24
+ {
25
+ from : "08:00" ,
26
+ to : "12:00" ,
27
+ } ,
28
+ {
29
+ from : "14:00" ,
30
+ to : "18:00" ,
31
+ } ,
32
+ ] ,
33
+ } ;
34
+ export const Default = {
35
+ args : {
36
+ businessHours : businessHours ,
37
+ } ,
38
+ } ;
39
+
40
+ export const Closed = {
41
+ args : {
42
+ ...Default . args ,
43
+ closed : true ,
44
+ } ,
45
+ } ;
Original file line number Diff line number Diff line change
1
+ <template >
2
+ <div
3
+ class =" m-business-hours-tile"
4
+ :class =" hasOpenClass"
5
+ >
6
+ <div class =" m-business-hours-tile__weekday" >
7
+ {{ businessHours.weekDay }}
8
+ </div >
9
+ <div class =" m-business-hours-tile__hours" >
10
+ <div v-if =" businessHours.openingHours.length === 0" >geschlossen</div >
11
+ <div
12
+ v-else
13
+ v-for =" time in businessHours.openingHours"
14
+ :key =" time.from"
15
+ >
16
+ {{ time.from }} - {{ time.to }}
17
+ </div >
18
+ </div >
19
+ </div >
20
+ </template >
21
+
22
+ <script setup lang="ts">
23
+ import { computed } from " vue" ;
24
+
25
+ import { BusinessHourType } from " ./BusinessHourType" ;
26
+
27
+ const LOCALES = " de-DE" ;
28
+
29
+ const props = withDefaults (
30
+ defineProps <{
31
+ closed? : boolean ;
32
+ businessHours: BusinessHourType ;
33
+ }>(),
34
+ {
35
+ closed: false ,
36
+ }
37
+ );
38
+
39
+ const hasOpenClass = computed (() =>
40
+ props .closed
41
+ ? " m-business-hours-tile--has-closed"
42
+ : " m-business-hours-tile--is-open"
43
+ );
44
+
45
+ /**
46
+ * Computes the short name of today's day.
47
+ *
48
+ * @returns {string} The short name of today's day (e.g., "Mo", "Di").
49
+ */
50
+ const todaysDayShortName = computed (() => {
51
+ const today = new Date ();
52
+ return today .toLocaleDateString (LOCALES , { weekday: " short" });
53
+ });
54
+
55
+ const isOpen = computed (() => {
56
+ return false ;
57
+ });
58
+ </script >
59
+
60
+ <style scoped></style >
You can’t perform that action at this time.
0 commit comments