Radios Config Module
The Radios Config Module holds your application's default/prototypal Tailwind CSS classes for Radio input elements in your application, excluding color palette classes (see Palette Config Modules for more info about palette modules).
app.vv.ts Use
You'll usually work with the Radios Config Module after it's already been merged into VueVentus VvConfig data.
Here's what that generally looks like in practice in a real world app context:
// ./src/app.vv.ts
import { VvConfig } from '@obewds/vueventus'
import type { ConfigVv } from '@obewds/vueventus'
let appVv: ConfigVv = VvConfig
appVv.radios.someProperty = 'some-value'
// ...
export default appVv
Import
However, if you need to import the compiled library version of the Radios Config Module, you can use:
import { Radios } from '@obewds/vueventus'
Radios.baseColors
Type: String
Default: "bg-gray-100 border-gray-400 dark:border-black ring-offset-white dark:ring-offset-gray-800"
The Radios.baseColors
parameter is meant to isolate any base color classes that would apply in addition to all palette colors.
Example
// ./src/app.vv.ts
appVv.radios.baseColors = '...'
Radios.border
Type: String
Default: ""
The Radios.border
parameter is meant to isolate the border specific atomic classes that don't pertain to already represented characteristics in VueVentus like color, size, etc.
AVOID: COLOR & SIZE
Atomic classes for this property should avoid using classes related to characteristics like color and size, which are already abstracted in VueVentus.
Example
// ./src/app.vv.ts
appVv.radios.border = '...'
Radios.outline
Type: String
Default: ""
The Radios.outline
parameter is meant to isolate the outline specific atomic classes that don't pertain to already represented characteristics in VueVentus like color, size, etc.
AVOID: COLOR & SIZE
Atomic classes for this property should avoid using classes related to characteristics like color and size, which are already abstracted in VueVentus.
Example
// ./src/app.vv.ts
appVv.radios.outline = '...'
Radios.ring
Type: String
Default: "focus:ring-offset-2 focus:ring-2"
The Radios.ring
parameter is meant to isolate the Tailwind CSS ring visualization interaction characteristics and requirements for an application's input elements. Tailwind CSS ring classes for example, are typically used in conjunction with the focus:
modifier for user focus interactions.
AVOID: COLOR & SIZE
Atomic classes for this property should avoid using classes related to characteristics like color and size, which are already abstracted in VueVentus.
Example
// ./src/app.vv.ts
appVv.radios.ring = '...'
Radios.rounding
Type: String
Default: ""
The Radios.rounding
parameter is meant to isolate the Tailwind CSS border rounding characteristics and requirements for an application's input elements.
AVOID: COLOR & SIZE
Atomic classes for this property should avoid using classes related to characteristics like color and size, which are already abstracted in VueVentus.
Example
// ./src/app.vv.ts
appVv.radios.rounding = '...'
Radios.shadow
Type: String
Default: ""
The Radios.shadow
parameter is meant to isolate the Tailwind CSS border shadow characteristics and requirements for an application's input elements.
AVOID: COLOR & SIZE
Atomic classes for this property should avoid using classes related to characteristics like color and size, which are already abstracted in VueVentus.
Example
// ./src/app.vv.ts
appVv.radios.shadow = '...'
Radios.sizes
Type: Object
Radios.sizes Properties | Radios.sizes Prop Values |
---|---|
"xs" | "h-3 w-3" |
"sm" | "h-4 w-4" |
"md" | "h-5 w-5" |
"lg" | "h-6 w-6" |
"xl" | "h-7 w-7" |
"2xl" | "h-8 w-8" |
Examples
// ./src/app.vv.ts
appVv.radios.sizes = {
'xs': '',
'sm': '',
'md': '',
'lg': '',
'xl': '',
'2xl': '',
}
// ./src/app.vv.ts
appVv.radios.sizes['xs'] = ''
appVv.radios.sizes['sm'] = ''
appVv.radios.sizes['md'] = ''
appVv.radios.sizes['lg'] = ''
appVv.radios.sizes['xl'] = ''
appVv.radios.sizes['2xl'] = ''
Radios.transition
Type: String
Default: "transition-colors ease-in-out duration-300"
The Radios.transition
parameter is meant to isolate the transition/animation characteristics and requirements for an application's input elements.
Example
// ./src/app.vv.ts
appVv.radios.transition = '...'
Radios.base()
Returns: String
Default: "bg-gray-100 border-gray-400 dark:border-black ring-offset-white dark:ring-offset-gray-800 focus:ring-offset-2 focus:ring-2 transition-colors ease-in-out duration-300"
The Radios.base()
method returns a joined String
of the atomic classes within the various base properties of the Radios Config Module object.
Example
<!-- ./src/components/SomeComponent.vue -->
<script setup lang="ts">
import appVv from '../app.vv'
</script>
<template>
<input type="radio" :class="appVv.radios.base()"/>
</template>
Radios.classes()
Returns: String
Default: "bg-gray-100 border-gray-400 dark:border-black ring-offset-white dark:ring-offset-gray-800 focus:ring-offset-2 focus:ring-2 transition-colors ease-in-out duration-300 h-5 w-5"
The Radios.classes()
method returns a joined String
of the atomic classes within the various base properties of the Radios Config Module object using the Radios.base()
method under the hood.
However, the Radios.classes()
method also returns Radios.getSizeClasses()
method classes in addition to the base property classes/values, which augments the returned value based on the optional argument value passed into the method.
Arguments
Args | Type | Status | Description |
---|---|---|---|
sizesKey | String | Optional | Property name/key of a Radios.sizes object |
The applicable values for the sizesKey
argument are set via the Radios.sizes property names/keys and atomic class values.
Examples
<!-- ./src/components/SomeComponent.vue -->
<script setup lang="ts">
import appVv from '../app.vv'
</script>
<template>
<!-- Regular Sized Radio -->
<input :class="appVv.radios.classes()"/>
<!-- Large Sized Radio -->
<input :class="appVv.radios.classes('lg')"/>
</template>
Radios.getSizeClasses()
Returns: String
Default: "h-5 w-5"
The Radios.getSizeClasses()
method returns text size related classes based on the optional argument value passed into the method. These size related classes come from the Radios.sizes
object property names/keys and values (of atomic classes).
Arguments
Args | Type | Status | Description |
---|---|---|---|
sizesKey | String | Optional | Property name/key of an Radios.sizes object |
The applicable values for the sizesKey
argument are set via the Radios.sizes property names/keys and atomic class values.
Examples
<!-- ./src/components/SomeComponent.vue -->
<script setup lang="ts">
import appVv from '../app.vv'
</script>
<template>
<!-- Regular Sized Radio -->
<input :class="appVv.radios.getSizeClasses()"/>
<!-- Large Sized Radio -->
<input :class="appVv.radios.getSizeClasses('lg')"/>
</template>
Module Code
// ./src/configs/Radios.ts
import type { ConfigRadios } from '../types/ConfigRadios'
import Transitions from './Transitions.js'
export default <ConfigRadios>{
baseColors: 'bg-gray-100 border-gray-400 dark:border-black ring-offset-white dark:ring-offset-gray-800',
border: '',
outline: '',
ring: 'focus:ring-offset-2 focus:ring-2',
rounding: '',
shadow: '',
transition: Transitions.classes('colors', 'inOut', '300'),
base: function () {
return [
this.baseColors,
this.border,
this.outline,
this.ring,
this.rounding,
this.shadow,
this.transition,
].join(' ').replace(/\s+/g,' ').trim()
},
sizes: {
'xs': 'h-3 w-3',
'sm': 'h-4 w-4',
'md': 'h-5 w-5',
'lg': 'h-6 w-6',
'xl': 'h-7 w-7',
'2xl': 'h-8 w-8',
},
getSizeClasses: function (sizesKey) {
const key = sizesKey && this.sizes[sizesKey] ? sizesKey : 'md'
return this.sizes[key]
},
classes: function (sizesKey) {
const sizes = sizesKey ? sizesKey : ''
return [
this.base(),
this.getSizeClasses(sizes),
].join(' ').replace(/\s+/g,' ').trim()
},
}