-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/dzangolab/vue into feat/upd…
…ate-email
- Loading branch information
Showing
8 changed files
with
356 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,216 @@ | ||
<template> | ||
<UiPage :title="$t('ui.data.title')" class="demo"> | ||
<template #toolbar> | ||
<router-link :to="{ name: 'ui' }" class="back"> | ||
{{ $t("common.back") }} | ||
</router-link> | ||
</template> | ||
|
||
<section> | ||
<h2>{{ $t("ui.data.usage.basic") }}</h2> | ||
|
||
<div class="section-content"> | ||
<!-- eslint-disable --> | ||
<SshPre language="html-vue"> | ||
<template> | ||
<Data label="Name" value="John Doe" /> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { Data } from "@dzangolab/vue3-ui"; | ||
</script> | ||
</SshPre> | ||
<!-- eslint-enable --> | ||
|
||
<Data :label="$t('ui.data.label.name')" :value="userData.name" /> | ||
</div> | ||
</section> | ||
|
||
<section> | ||
<h2>{{ $t("ui.data.usage.displayObject") }}</h2> | ||
|
||
<div class="section-content"> | ||
<!-- eslint-disable --> | ||
<SshPre language="html-vue"> | ||
<template> | ||
<Data | ||
:value="userData" | ||
data-key="email" | ||
label="Email" | ||
/> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { Data } from "@dzangolab/vue3-ui"; | ||
|
||
const userData = { | ||
email: "john.doe@example.com", | ||
name: "John Doe", | ||
}; | ||
</script> | ||
</SshPre> | ||
<!-- eslint-enable --> | ||
|
||
<Data | ||
:label="$t('ui.data.label.email')" | ||
:value="userData" | ||
data-key="email" | ||
/> | ||
</div> | ||
</section> | ||
|
||
<section> | ||
<h2>{{ $t("ui.data.usage.structuredData") }}</h2> | ||
|
||
<div class="section-content"> | ||
<!-- eslint-disable --> | ||
<SshPre language="html-vue"> | ||
<template> | ||
<GridContainer> | ||
<Data v-for="(data, index) in data" :key="index" v-bind="data" /> | ||
</GridContainer> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { Data, GridContainer } from "@dzangolab/vue3-ui"; | ||
|
||
const data = [ | ||
{ | ||
label: "Name", | ||
value: "John Doe", | ||
}, | ||
{ | ||
label: "Age", | ||
value: 30, | ||
}, | ||
{ | ||
label: "Email", | ||
value: { | ||
email: "john.doe@example.com", | ||
user: "John Doe", | ||
}, | ||
dataKey: "email", | ||
}, | ||
{ | ||
label: "Address", | ||
value: "123 Main St, Springfield, USA", | ||
}, | ||
{ | ||
label: "Status", | ||
value: "Active", | ||
}, | ||
]; | ||
</script> | ||
</SshPre> | ||
<!-- eslint-enable --> | ||
|
||
<GridContainer> | ||
<Data | ||
v-for="(data, index) in structuredData" | ||
:key="index" | ||
v-bind="data" | ||
/> | ||
</GridContainer> | ||
</div> | ||
</section> | ||
|
||
<section> | ||
<h2>{{ $t("ui.data.usage.separatorSlot") }}</h2> | ||
|
||
<div class="section-content"> | ||
<!-- eslint-disable --> | ||
<SshPre language="html-vue"> | ||
<template> | ||
<Data | ||
v-for="(data, index) in data" | ||
:key="index" | ||
v-bind="data" | ||
direction="horizontal" | ||
> | ||
<template #separator>:</template> | ||
</Data> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { Data } from "@dzangolab/vue3-ui"; | ||
|
||
const data = [ | ||
{ | ||
label: "Name", | ||
value: "John Doe", | ||
}, | ||
{ | ||
label: "Age", | ||
value: 30, | ||
}, | ||
{ | ||
label: "Email", | ||
value: { | ||
email: "john.doe@example.com", | ||
user: "John Doe", | ||
}, | ||
dataKey: "email", | ||
}, | ||
{ | ||
label: "Address", | ||
value: "123 Main St, Springfield, USA", | ||
}, | ||
{ | ||
label: "Status", | ||
value: "Active", | ||
}, | ||
]; | ||
</script> | ||
</SshPre> | ||
<!-- eslint-enable --> | ||
|
||
<Data | ||
v-for="(data, index) in structuredData" | ||
:key="index" | ||
v-bind="data" | ||
direction="horizontal" | ||
> | ||
<template #separator>:</template> | ||
</Data> | ||
</div> | ||
</section> | ||
</UiPage> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { Data, GridContainer } from "@dzangolab/vue3-ui"; | ||
import UiPage from "../UiPage.vue"; | ||
const structuredData = [ | ||
{ | ||
label: "Name", | ||
value: "John Doe", | ||
}, | ||
{ | ||
label: "Age", | ||
value: 30, | ||
}, | ||
{ | ||
label: "Email", | ||
value: { | ||
email: "john.doe@example.com", | ||
user: "John Doe", | ||
}, | ||
dataKey: "email", | ||
}, | ||
{ | ||
label: "Address", | ||
value: "123 Main St, Springfield, USA", | ||
}, | ||
{ | ||
label: "Status", | ||
value: "Active", | ||
}, | ||
]; | ||
const userData = { | ||
email: "john.doe@example.com", | ||
name: "John Doe", | ||
}; | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<template> | ||
<div :class="`data direction-${direction}`"> | ||
<span class="data-label">{{ label }}</span> | ||
<span v-if="slots.separator" class="separator"> | ||
<slot name="separator"></slot> | ||
</span> | ||
<span class="data-value"> | ||
<slot name="value"> | ||
{{ displayValue }} | ||
</slot> | ||
</span> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts"> | ||
export default { | ||
name: "DataElement", | ||
}; | ||
</script> | ||
|
||
<script setup lang="ts"> | ||
import { computed, useSlots } from "vue"; | ||
import type { PropType } from "vue"; | ||
const props = defineProps({ | ||
dataKey: { | ||
default: undefined, | ||
type: String, | ||
}, | ||
direction: { | ||
default: "vertical", | ||
type: String, | ||
validator: (value: string) => ["horizontal", "vertical"].includes(value), | ||
}, | ||
label: { | ||
type: [String, Number, Object] as PropType<string | number>, | ||
required: true, | ||
}, | ||
value: { | ||
type: [Object, String, Number] as PropType<string | number | object>, | ||
required: true, | ||
}, | ||
}); | ||
const slots = useSlots(); | ||
const displayValue = computed(() => { | ||
if ( | ||
props.dataKey && | ||
typeof props.value === "object" && | ||
props.value !== null && | ||
props.dataKey in props.value | ||
) { | ||
return props.value[props.dataKey as keyof typeof props.value]; | ||
} | ||
return props.value; | ||
}); | ||
</script> | ||
|
||
<style lang="css"> | ||
@import "../assets/css/data.css"; | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
.data { | ||
display: flex; | ||
flex-direction: column; | ||
gap: 0.25rem; | ||
} | ||
|
||
.data.direction-horizontal > .data-label { | ||
--_width: var(--data-label-width, 8rem); | ||
|
||
overflow-x: hidden; | ||
text-overflow: ellipsis; | ||
width: var(--_width); | ||
} | ||
|
||
.data > .data-label { | ||
font-size: 0.875rem; | ||
line-height: 1.5; | ||
} | ||
|
||
.data > .data-value { | ||
font-weight: 500; | ||
line-height: 1.5; | ||
} | ||
|
||
.data > .separator { | ||
display: none; | ||
} | ||
|
||
@media screen and (min-width: 576px) { | ||
.data.direction-horizontal { | ||
align-items: center; | ||
flex-direction: row; | ||
gap: 1rem; | ||
} | ||
|
||
.data > .separator { | ||
display: block; | ||
} | ||
} |
Oops, something went wrong.