aboutsummaryrefslogtreecommitdiffstats
path: root/web/components/Panel.vue
blob: 1f2d22e04dbb9b055f280cc89f6598a80743726b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<script setup lang="ts">
import { ArrowRight } from 'lucide-vue-next';
import { defineProps, type FunctionalComponent, type PropType } from 'vue';

defineProps({
  kind: {
    type: String as PropType<"normal" | "error" | "success" | "emphasis">,
    required: false,
    default: 'normal',
  },
  title: {
    type: String,
    required: false,
    default: '',
  },
  breadcrumbs: {
    type: Array as PropType<Array<{ text: string, to: string }>>,
    required: false,
    default: () => [],
  },
  icon: {
    type: Object as PropType<FunctionalComponent>,
    default: null
  }
});
</script>
<template>
  <div class="card" :class="kind">
    <div v-if="title" class="card-header">
      <div class="header-left">
        <component :is="icon" v-if="icon" />
        <div class="card-title-container">
          <span v-for="(breadcrumb, index) in breadcrumbs" class="breadcrumb" :key="index">
            <NuxtLink :to="breadcrumb.to">{{ breadcrumb.text }}</NuxtLink>
            <ArrowRight v-if="index != breadcrumbs.length - 1" />
          </span>
          <span class="card-title"> {{ title }} </span>
        </div>
      </div>
      
      <slot name="actions" />
    </div>
    <slot />
  </div>
</template>

<style>
div.card {
  padding: 1rem; 
  border-radius: 0.5rem; 
}

div.card-header {
  padding: 1rem 1rem;
  margin: -1rem -1rem 0 -1rem;
  border-top-left-radius: 0.5rem;
  border-top-right-radius: 0.5rem;;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

div.header-left {
  display: flex;
  line-height: 1;
  align-items: center;
  gap: 0.5rem;
}

div.header-left > svg {
  width: 1.3rem;
  height: 1.3rem;
}

span.card-title {
  font-size: 1.5rem;
  font-weight: 700;
}

span.breadcrumb {
  font-size: 1.2rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

span.breadcrumb > svg {
  width: 1.2rem;
  height: 1.2rem;
  color: var(--color-text-muted);
}

span.breadcrumb > a {
  color: var(--color-text-muted);
}

span.breadcrumb > a:hover {
  color: var(--color-primary);
}

div.normal {
  background-color: white;
  border: 0.1rem solid var(--color-border);
}

div.normal .card-header {
  background-color: var(--color-background-muted);
  border-bottom: 1px solid var(--color-border);
  margin: -1rem -1rem 1rem -1rem;
}

div.error {
  background-color: var(--color-error-light);
  border: 0.1rem solid var(--color-border-error-light);
}

div.success {
  background-color: var(--color-success-light);
  border: 0.1rem solid var(--color-border-success-light);
}

div.emphasis {
  background-color: var(--color-background-primary);
  border: 0.1rem solid var(--color-border-primary-light);
}
</style>