-
Notifications
You must be signed in to change notification settings - Fork 0
feat(FoRadio): First implementation #136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
5b5c434
feat(FoRadio): First implementation
michaelcozzolino c38c6fe
feat(FoImageRadio): First implementation
michaelcozzolino a9f92e1
feat(RadioDocs): First implementation
michaelcozzolino 8922582
feat(FoRadio): Add snapshots
michaelcozzolino 9e175ab
Update packages/docs/Next/Forms/Radio/RadioListGroup.vue
michaelcozzolino 4e68174
Update packages/docs/Next/Forms/Radio/RadioHorizontalListGroup.vue
michaelcozzolino d10b4f9
fix(FoRadio): Remove unused types
michaelcozzolino 2c07f7a
Merge remote-tracking branch 'origin/feat/radio' into feat/radio
michaelcozzolino File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,15 @@ | ||
| import type { Colorable, Disableable, MaybeStringId, Sizable, Validity } from '@/Lib'; | ||
| import type { Image } from '@/Types'; | ||
| import type { WithHelperText, WithLabel } from '@/UI/Components'; | ||
|
|
||
| interface RadioValue { | ||
| value: string; | ||
| } | ||
|
|
||
| export interface RadioProps extends MaybeStringId, RadioValue, Colorable, Disableable, Sizable, Validity, WithLabel, WithHelperText { | ||
| isInset?: boolean; | ||
| } | ||
|
|
||
| export interface ImageRadioProps extends RadioValue { | ||
| image: Image; | ||
| } |
This file contains hidden or 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 @@ | ||
| export * from '@/UI/Forms/Radio/Types/Radio'; |
This file contains hidden or 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,24 @@ | ||
| <template> | ||
| <FoLabel class="custom-option p-0"> | ||
| <span class="w-full"> | ||
| <img :src="image.src" | ||
| :alt="image.alt" | ||
| > | ||
| </span> | ||
|
|
||
| <input v-model="checkedValue" | ||
| class="radio hidden" | ||
| type="radio" | ||
| :value="value" | ||
| > | ||
| </FoLabel> | ||
| </template> | ||
|
|
||
| <script setup lang="ts"> | ||
| import type { ImageRadioProps } from '@/UI/Forms'; | ||
| import { FoLabel } from '@/UI/Components/Label/Internal'; | ||
|
|
||
| defineProps<ImageRadioProps>(); | ||
|
|
||
| const checkedValue = defineModel<string>({ required: true }); | ||
| </script> | ||
This file contains hidden or 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,85 @@ | ||
| <template> | ||
| <component :is="isInJoin ? FoFragment : 'div'" | ||
| :class="isInJoin === false && ['flex', hasLabelAndHelperText ? 'gap-3' : 'items-center gap-1']" | ||
| v-bind="isInJoin === false && reactiveOmit($attrs, 'class')" | ||
| > | ||
| <input :id="id" | ||
| v-model="checkedValue" | ||
| :value="value" | ||
| type="radio" | ||
| :class="isInJoin ? [$attrs?.class, joinItemClass] : [ | ||
| $attrs?.class, | ||
| 'radio', | ||
| colorClass, | ||
| sizeClass, | ||
| validityClass, | ||
| joinItemClass, | ||
| hasLabelAndHelperText && 'mt-2', | ||
| isInset && 'radio-inset', | ||
| ]" | ||
| :disabled="isDisabled" | ||
| :aria-label="isInJoin ? label : ''" | ||
| > | ||
|
|
||
| <FoLabel v-if="isInJoin === false && label !== undefined" | ||
| :for="id" | ||
| :class="hasLabelAndHelperText && 'flex flex-col'" | ||
| > | ||
| <span class="text-base"> | ||
| {{ label }} | ||
| </span> | ||
|
|
||
| <FoHelperText v-if="helperText !== undefined"> | ||
| {{ helperText }} | ||
| </FoHelperText> | ||
| </FoLabel> | ||
| </component> | ||
| </template> | ||
|
|
||
| <script setup lang="ts"> | ||
| import type { ComponentName } from '@/Lib'; | ||
| import type { RadioProps } from '@/UI/Forms/Radio'; | ||
| import { useFlyonUIVueAppConfig } from '@/Lib'; | ||
| import { useClass } from '@/Lib/UseClass/Internal'; | ||
| import { useColor } from '@/Lib/UseColor/Internal'; | ||
| import { useElementId } from '@/Lib/UseIdentifiable/Internal'; | ||
| import { useSize } from '@/Lib/UseSize/Internal'; | ||
| import { useValidity } from '@/Lib/UseValidity/Internal'; | ||
| import { FoFragment } from '@/UI/Components/Fragment/Internal'; | ||
| import { FoHelperText } from '@/UI/Components/HelperText/Internal'; | ||
| import { FoLabel } from '@/UI/Components/Label/Internal'; | ||
| import { isInJoinInjectionKey, useJoinItem } from '@/UI/Forms/Join/Internal'; | ||
| import { reactiveOmit } from '@vueuse/core'; | ||
| import { computed, inject } from 'vue'; | ||
|
|
||
| defineOptions({ | ||
| inheritAttrs: false, | ||
| }); | ||
|
|
||
| const props = withDefaults(defineProps<RadioProps>(), { | ||
| isValid: undefined, | ||
| }); | ||
|
|
||
| const checkedValue = defineModel<string>({ required: true }); | ||
|
|
||
| const componentName: ComponentName = 'FoRadio'; | ||
| const { config } = useFlyonUIVueAppConfig(); | ||
|
|
||
| const isInJoin: boolean = inject(isInJoinInjectionKey, false); | ||
|
|
||
| const id = useElementId((): string | undefined => props.id); | ||
|
|
||
| const [ | ||
| colorClass, | ||
| sizeClass, | ||
| validityClass, | ||
| joinItemClass, | ||
| ] = [ | ||
| useColor(config, componentName, () => props.color), | ||
| useSize(config, componentName, () => props.size), | ||
| useValidity(() => props.isValid), | ||
| useClass(isInJoin, () => `btn btn-soft ${useJoinItem(isInJoin).value}`), | ||
| ]; | ||
|
|
||
| const hasLabelAndHelperText = computed((): boolean => props.label !== undefined && props.helperText !== undefined); | ||
| </script> |
This file contains hidden or 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,2 @@ | ||
| export { default as FoImageRadio } from '@/UI/Forms/Radio/UI/FoImageRadio.vue'; | ||
| export { default as FoRadio } from '@/UI/Forms/Radio/UI/FoRadio.vue'; |
This file contains hidden or 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,2 @@ | ||
| export * from '@/UI/Forms/Radio/Types'; | ||
| export * from '@/UI/Forms/Radio/UI'; |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,87 @@ | ||
| # Radio | ||
|
|
||
| ### Default | ||
|
|
||
| <RadioDocs section="default" /> | ||
michaelcozzolino marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| ### With label and helper text | ||
|
|
||
| <RadioDocs section="with-label-and-helper-text" /> | ||
|
|
||
| ### Insets | ||
|
|
||
| <RadioDocs section="inset" /> | ||
|
|
||
| ## Colors | ||
|
|
||
| ### Solid | ||
|
|
||
| <RadioDocs section="color" /> | ||
|
|
||
| ### Solid insets | ||
|
|
||
| <RadioDocs section="inset-color" /> | ||
|
|
||
| ### Custom colors | ||
|
|
||
| <RadioDocs section="custom-color" /> | ||
|
|
||
| ## Sizes | ||
|
|
||
| ### Default sizes | ||
|
|
||
| <RadioDocs section="size" /> | ||
|
|
||
| ### Inset sizes | ||
|
|
||
| <RadioDocs section="inset-size" /> | ||
|
|
||
| ## States | ||
|
|
||
| ### Validation states | ||
|
|
||
| <RadioDocs section="validation-state" /> | ||
|
|
||
| ## Illustrations | ||
|
|
||
| ### Disabled | ||
|
|
||
| <RadioDocs section="disabled" /> | ||
|
|
||
| ### Inline group | ||
|
|
||
| <RadioDocs section="inline-group" /> | ||
|
|
||
| ### Vertical group | ||
|
|
||
| <RadioDocs section="vertical-group" /> | ||
|
|
||
| [//]: # (todo: radio in dropdown) | ||
|
|
||
| ### List group | ||
|
|
||
| <RadioDocs section="list-group" /> | ||
|
|
||
| ### Horizontal list group | ||
|
|
||
| <RadioDocs section="horizontal-list-group" /> | ||
|
|
||
| ### Button group | ||
|
|
||
| <RadioDocs section="button-group" /> | ||
|
|
||
| ## Custom options | ||
|
|
||
| ### Image | ||
|
|
||
| <RadioDocs section="image" /> | ||
|
|
||
| ## Api | ||
|
|
||
| ### Props | ||
|
|
||
| <RadioDocs section="props" /> | ||
|
|
||
| ### Slots | ||
|
|
||
| <RadioDocs section="slots" /> | ||
This file contains hidden or 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,34 @@ | ||
| <template> | ||
| <FoRadio v-model="selectedValue" | ||
| class="[--input-color:pink]" | ||
| label="FlyonUI variable" | ||
| :value="selectedValue" | ||
| /> | ||
|
|
||
| <FoRadio v-model="selectedValue" | ||
| class="checked:text-pink-300" | ||
| label="Tailwind utility colors" | ||
| :value="selectedValue" | ||
| /> | ||
|
|
||
| <FoRadio v-model="selectedValue" | ||
| class="[--input-color:green]" | ||
| label="FlyonUI variable" | ||
| :value="selectedValue" | ||
| is-inset | ||
| /> | ||
|
|
||
| <FoRadio v-model="selectedValue" | ||
| class="checked:text-green-700" | ||
| label="FlyonUI variable" | ||
| :value="selectedValue" | ||
| is-inset | ||
| /> | ||
| </template> | ||
|
|
||
| <script setup lang="ts"> | ||
| import { FoRadio } from 'flyonui-vue'; | ||
| import { ref } from 'vue'; | ||
|
|
||
| const selectedValue = ref<string>('value'); | ||
| </script> | ||
michaelcozzolino marked this conversation as resolved.
Show resolved
Hide resolved
|
||
This file contains hidden or 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,21 @@ | ||
| <template> | ||
| <FoRadio v-model="selectedValue" | ||
| label="Default" | ||
| :value="defaultValue" | ||
| /> | ||
|
|
||
| <FoRadio v-model="selectedValue" | ||
| label="Checked" | ||
| :value="checkedValue" | ||
| /> | ||
| </template> | ||
|
|
||
| <script setup lang="ts"> | ||
| import { FoRadio } from 'flyonui-vue'; | ||
| import { ref } from 'vue'; | ||
|
|
||
| const defaultValue = 'default'; | ||
| const checkedValue = 'checked'; | ||
|
|
||
| const selectedValue = ref<typeof defaultValue | typeof checkedValue>('checked'); | ||
| </script> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.