-
Notifications
You must be signed in to change notification settings - Fork 5
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
1 parent
002c708
commit 9d52d4e
Showing
7 changed files
with
154 additions
and
40 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<template x-component:hui="radio-group" x-modelable="value" x-data="{value : null}"> | ||
<slot></slot> | ||
<script> | ||
return { | ||
isChecked(el) { | ||
return $vui.$data(el).$prop('value') === this.value | ||
}, | ||
check(val) { | ||
this.value = val | ||
} | ||
} | ||
</script> | ||
</template> | ||
|
||
<template x-component:hui="radio-group-option" x-data="{ | ||
get checked() {return $api.context.isChecked($el)}, | ||
}" @click="$api.onCheck()"> | ||
<slot></slot> | ||
<script> | ||
return { | ||
onMounted() { | ||
let container = this.$closest('radio-group') | ||
if (!container) throw Error('radio-group-option should be contained in radio-group') | ||
}, | ||
get context() { return this.$of('radio-group') }, | ||
onCheck() { | ||
this.context.check(this.$prop('value')) | ||
} | ||
} | ||
</script> | ||
</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
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,98 @@ | ||
<head> | ||
<!-- | ||
<script src="https://unpkg.com/@vimesh/style" defer></script> | ||
<script src="https://unpkg.com/@vimesh/ui"></script> | ||
<script src="https://unpkg.com/alpinejs" defer></script> | ||
--> | ||
|
||
<script src="/node_modules/@vimesh/style/dist/vs.dev.js" defer></script> | ||
<script src="/node_modules/@vimesh/ui/dist/vui.dev.js"></script> | ||
<script src="/node_modules/alpinejs/dist/cdn.js" defer></script> | ||
|
||
<script> | ||
$vui.config.importMap = { | ||
"*": '/components/${component}.html' | ||
} | ||
</script> | ||
<style> | ||
[x-cloak] { | ||
display: none !important; | ||
} | ||
</style> | ||
|
||
<script> | ||
let data = { | ||
active: 'access-2', | ||
access: [ | ||
{ | ||
id: 'access-1', | ||
name: 'Public access', | ||
description: 'This project would be available to anyone who has the link', | ||
}, | ||
{ | ||
id: 'access-2', | ||
name: 'Private to Project Members', | ||
description: 'Only members of this project would be able to access', | ||
}, | ||
{ | ||
id: 'access-3', | ||
name: 'Private to you', | ||
description: 'You are the only one able to access this project', | ||
}, | ||
] | ||
} | ||
</script> | ||
</head> | ||
|
||
<body x-cloak x-import="hui/radio-group" class="p-2" x-data="data"> | ||
|
||
<div class="max-w-xl p-12"> | ||
<a href="/">Link before</a> | ||
<hui-radio-group x-model="active"> | ||
<fieldset class="space-y-4"> | ||
<legend> | ||
<h2 class="text-xl">Privacy setting</h2> | ||
</legend> | ||
<div class="-space-y-px rounded-md bg-white"> | ||
<template x-for="(item, i) in access" :key="item.id"> | ||
<hui-radio-group-option :value="item.id" :class=" | ||
[ | ||
// Rounded corners | ||
i === 0 ? 'rounded-tl-md rounded-tr-md' : '', | ||
access.length - 1 === i ? 'rounded-bl-md rounded-br-md' : '', | ||
// Shared | ||
'relative border p-4 flex focus:outline-none', | ||
active ? 'bg-indigo-50 border-indigo-200 z-10' : 'border-gray-200' | ||
] | ||
"> | ||
<div class="flex w-full items-center justify-between"> | ||
<div class="ml-3 flex cursor-pointer flex-col"> | ||
<span :class="[ | ||
'block text-sm font-medium leading-5', | ||
active ? 'text-indigo-900' : 'text-gray-900', | ||
]" x-text="item.name"> | ||
</span> | ||
<span | ||
:class="['block text-sm leading-5', active ? 'text-indigo-700' : 'text-gray-500']" | ||
x-text="item.description"> | ||
</span> | ||
</div> | ||
<div> | ||
<template x-if="checked"> | ||
<svg xmlns="http:https://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" | ||
stroke="currentColor" class="h-5 w-5 text-indigo-500"> | ||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" | ||
d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z" /> | ||
</svg> | ||
</template> | ||
</div> | ||
</div> | ||
</hui-radio-group-option> | ||
</template> | ||
</div> | ||
</fieldset> | ||
</hui-radio-group> | ||
<a href="/">Link after</a> | ||
</div> | ||
</body> |
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "@vimesh/headless", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"repository": "https://github.com/vimeshjs/vimesh-headless.git", | ||
"author": "Jacky ZHANG <[email protected]>", | ||
"license": "MIT", | ||
|
@@ -10,7 +10,7 @@ | |
"dependencies": {}, | ||
"devDependencies": { | ||
"@vimesh/style": "^1.0.0", | ||
"@vimesh/ui": "^0.9.5", | ||
"@vimesh/ui": "^0.9.7", | ||
"alpinejs": "^3.10.5", | ||
"http-server": "^14.1.1" | ||
} | ||
|