-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
295 additions
and
25 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<script lang="ts" setup> | ||
import { computed } from 'vue' | ||
const model = defineModel({ required: true }) | ||
// Fixes Vue issue not supporting non-boolean values | ||
// https://github.com/vuejs/core/issues/5775 | ||
const modelBool = computed({ | ||
get() { | ||
return !!model.value | ||
}, | ||
set(value: any) { | ||
model.value = value | ||
}, | ||
}) | ||
</script> | ||
|
||
<template> | ||
<input v-model="modelBool" type="checkbox"> | ||
</template> |
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,26 @@ | ||
<script lang="ts" setup> | ||
import { reactive } from 'vue' | ||
import { getTimestamp } from 'zeed' | ||
import { OuiDatetime } from '../lib' | ||
const state = reactive({ | ||
value: getTimestamp(), | ||
}) | ||
</script> | ||
|
||
<template> | ||
<Story auto-props-disabled> | ||
<template #controls> | ||
<HstText v-model="state.value" title="Data URI" /> | ||
</template> | ||
<Variant title="Default"> | ||
<template #default> | ||
<div> | ||
<OuiDatetime | ||
v-model="state.value" | ||
/> | ||
</div> | ||
</template> | ||
</Variant> | ||
</Story> | ||
</template> |
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,40 @@ | ||
<script lang="ts" setup> | ||
import { computed } from 'vue' | ||
import { getTimestamp } from 'zeed' | ||
const model = defineModel<number>({ | ||
required: true, | ||
default: getTimestamp(), | ||
}) | ||
const date = computed({ | ||
get() { | ||
const mdate = new Date(model.value) | ||
const date = new Date() | ||
date.setUTCFullYear(mdate.getFullYear()) | ||
date.setUTCMonth(mdate.getMonth()) | ||
date.setUTCDate(mdate.getDate()) | ||
date.setUTCHours(mdate.getHours()) | ||
date.setUTCMinutes(mdate.getMinutes()) | ||
date.setUTCSeconds(mdate.getSeconds()) | ||
date.setUTCMilliseconds(mdate.getMilliseconds()) | ||
return date.toISOString().slice(0, 16) | ||
}, | ||
set(value) { | ||
const [y, m, d, hh, mm] = value.replace(/[^\d]/gim, ' ').split(' ') | ||
const date = new Date() | ||
date.setFullYear(+y) | ||
date.setMonth(+m - 1) | ||
date.setDate(+d) | ||
date.setHours(+hh) | ||
date.setMinutes(+mm) | ||
date.setSeconds(0) | ||
date.setMilliseconds(0) | ||
model.value = date.getTime() | ||
}, | ||
}) | ||
</script> | ||
|
||
<template> | ||
<input v-model="date" type="datetime-local"> | ||
</template> |
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,25 @@ | ||
<script lang="ts" setup> | ||
import { reactive } from 'vue' | ||
import { OuiFile } from '../lib' | ||
const state = reactive({ | ||
value: '', | ||
}) | ||
</script> | ||
|
||
<template> | ||
<Story auto-props-disabled> | ||
<template #controls> | ||
<HstText v-model="state.value" title="Data URI" /> | ||
</template> | ||
<Variant title="Default"> | ||
<template #default> | ||
<div> | ||
<OuiFile | ||
v-model="state.value" | ||
/> | ||
</div> | ||
</template> | ||
</Variant> | ||
</Story> | ||
</template> |
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,43 @@ | ||
<script lang="ts" setup> | ||
import { useFileDialog } from '@vueuse/core' | ||
import type { LoggerInterface } from 'zeed' | ||
import { Logger, createPromise } from 'zeed' | ||
const log: LoggerInterface = Logger('oui-file') | ||
const { files, open, reset, onChange } = useFileDialog({ | ||
accept: 'image/*', | ||
multiple: false, | ||
}) | ||
const model = defineModel<string | undefined | null>({ required: true }) | ||
async function fileToDataURI(file: File): Promise<string | undefined> { | ||
const [promise, resolve] = createPromise<string | undefined> () | ||
const fileReader = new FileReader() | ||
fileReader.addEventListener('error', resolve) | ||
fileReader.addEventListener('abort', resolve) | ||
fileReader.addEventListener('loadend', e => resolve(fileReader.result)) | ||
fileReader.readAsDataURL(file) | ||
return promise | ||
} | ||
onChange(async () => { | ||
const file = files.value?.[0] | ||
if (file) { | ||
const url = await fileToDataURI(file) | ||
log('url', url) | ||
model.value = url | ||
reset() | ||
} | ||
}) | ||
</script> | ||
|
||
<template> | ||
<div> | ||
<img v-if="model" :src="model"> | ||
<button @click.prevent="() => open()"> | ||
Choose file... | ||
</button> | ||
</div> | ||
</template> |
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,28 @@ | ||
<script lang="ts" setup> | ||
import { reactive } from 'vue' | ||
import { OuiSwitch } from '../lib' | ||
const state = reactive({ | ||
value: false, | ||
}) | ||
</script> | ||
|
||
<template> | ||
<Story auto-props-disabled> | ||
<template #controls> | ||
<HstCheckbox v-model="state.value" title="Show footer" /> | ||
</template> | ||
<Variant title="Default"> | ||
<template #default> | ||
<div> | ||
<label> | ||
<OuiSwitch | ||
v-model="state.value" | ||
/> | ||
Just a switch | ||
</label> | ||
</div> | ||
</template> | ||
</Variant> | ||
</Story> | ||
</template> |
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,20 @@ | ||
<script lang="ts" setup> | ||
import { computed } from 'vue' | ||
const model = defineModel({ required: true }) | ||
// Fixes Vue issue not supporting non-boolean values | ||
// https://github.com/vuejs/core/issues/5775 | ||
const modelBool = computed({ | ||
get() { | ||
return !!model.value | ||
}, | ||
set(value: any) { | ||
model.value = value | ||
}, | ||
}) | ||
</script> | ||
|
||
<template> | ||
<input v-model="modelBool" type="checkbox" class="oui-switch"> | ||
</template> |
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,60 @@ | ||
<script lang="ts" setup> | ||
import { OuiTooltipActivator } from './index' | ||
function initialState() { | ||
return { } | ||
} | ||
</script> | ||
|
||
<template> | ||
<Story auto-props-disabled> | ||
<template #controls="{ state }"> | ||
<HstCheckbox v-model="state.show" title="show" /> | ||
</template> | ||
<Variant title="Simple popover" :init-state="initialState"> | ||
<template #default> | ||
<p> | ||
Just another set of UI components for <i | ||
tooltip="A longer tooltip | ||
in multiple lines | ||
Yeah!" | ||
>Vue.js</i> with a proper French-sounding name | ||
</p> | ||
<button tooltip="Hello, I am a tooltip"> | ||
Tooltip | ||
</button> | ||
<br> | ||
|
||
<p>Also boxes work:</p> | ||
<div tooltip="Box" style="background-color: yellow;"> | ||
Demo | ||
</div> | ||
|
||
<OuiTooltipActivator /> | ||
</template> | ||
</Variant> | ||
</story> | ||
</template> | ||
|
||
<style> | ||
[tooltip] { | ||
text-decoration: underline; | ||
text-decoration-style: dotted; | ||
} | ||
</style> | ||
|
||
<docs lang="md"> | ||
# Tooltip | ||
|
||
Place the following somewhere, best in your `App.vue`, to activate tooltip support: | ||
|
||
```vue | ||
<OuiTooltipActivator /> | ||
``` | ||
|
||
Now simply add the `tooltip` attribute whereever you want: | ||
|
||
```html | ||
<button tooltip="Hello, I am a tooltip"> | ||
``` | ||
</docs> |
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
Oops, something went wrong.