Skip to content

Commit

Permalink
UITagRadio
Browse files Browse the repository at this point in the history
  • Loading branch information
nighca committed Oct 9, 2024
1 parent ee67a3e commit faf69ea
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 51 deletions.
2 changes: 1 addition & 1 deletion spx-gui/src/components/asset/library/AssetLibraryModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ async function handleAssetClick(asset: AssetData) {
padding: var(--ui-gap-middle);
gap: 12px;
background: var(--ui-color-grey-200);
border-right: 1px solid var(--ui-color-grey-400);
}
.main {
flex: 1 1 0;
Expand Down
7 changes: 5 additions & 2 deletions spx-gui/src/components/ui/UITag.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,18 @@ defineProps<{
border-radius: var(--ui-border-radius-2);
cursor: pointer;
white-space: nowrap;
transition: .3s;
&.type-primary {
color: var(--ui-color-grey-100);
background: var(--ui-color-primary-main);
border-color: var(--ui-color-primary-main);
}
&.type-boring {
background: var(--ui-color-grey-600);
border-color: var(--ui-color-grey-600);
color: var(--ui-color-grey-900);
background: var(--ui-color-grey-300);
border-color: var(--ui-color-grey-300);
}
}
</style>
46 changes: 0 additions & 46 deletions spx-gui/src/components/ui/button-radio/UIButtonRadio.vue

This file was deleted.

2 changes: 0 additions & 2 deletions spx-gui/src/components/ui/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,4 @@ export { default as UIEditorBackdropItem } from './block-items/UIEditorBackdropI
export { default as UIBackdropItem } from './block-items/UIBackdropItem.vue'
export { default as UIEditorWidgetItem } from './block-items/UIEditorWidgetItem.vue'
export { default as UIPagination } from './UIPagination.vue'
export { default as UIButtonRadioGroup } from './button-radio/UIButtonRadioGroup.vue'
export { default as UIButtonRadio } from './button-radio/UIButtonRadio.vue'
export * from './select'
27 changes: 27 additions & 0 deletions spx-gui/src/components/ui/radio/UITagRadio.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<template>
<UITag
:type="isActive ? 'primary' : 'boring'"
@click="handleClick"
>
<slot></slot>
</UITag>
</template>

<script setup lang="ts">
import { inject, computed } from 'vue'
import UITag from '../UITag.vue'
import { radioGroupValueKey, updateRadioValueKey } from './UITagRadioGroup.vue'
const props = defineProps<{
value: string
}>()
const radioGroupValue = inject(radioGroupValueKey)
const updateRadioValue = inject(updateRadioValueKey)
const isActive = computed(() => radioGroupValue?.value === props.value)
const handleClick = () => {
updateRadioValue?.(props.value)
}
</script>
3 changes: 3 additions & 0 deletions spx-gui/src/components/ui/radio/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
export { default as UIRadio } from './UIRadio.vue'
export { default as UIRadioGroup } from './UIRadioGroup.vue'
// TODO: consider merging `UITagRadio` with `UIRadio` (with prop `style="tag"`)
export { default as UITagRadio } from './UITagRadio.vue'
export { default as UITagRadioGroup } from './UITagRadioGroup.vue'

0 comments on commit faf69ea

Please sign in to comment.