Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 16 additions & 22 deletions packages/core/src/Lib/UseColor/Internal/Lib/UseColor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,17 @@ export function useColor(
componentName: MaybeRefOrGetter<ColorableComponentName>,
color: MaybeRefOrGetter<Color | undefined>,
): ComputedRef<string> {
const textClasses: Record<Color, string> = {
neutral: 'text-neutral',
primary: 'text-primary',
secondary: 'text-secondary',
accent: 'text-accent',
info: 'text-info',
success: 'text-success',
warning: 'text-warning',
error: 'text-error',
};

return useComponentClass<ColorableComponentName, Color>(
componentName,
{
Expand Down Expand Up @@ -62,17 +73,8 @@ export function useColor(
warning: 'divider-warning',
error: 'divider-error',
},
FoHeading: {
neutral: 'text-neutral',
primary: 'text-primary',
secondary: 'text-secondary',
accent: 'text-accent',
info: 'text-info',
success: 'text-success',
warning: 'text-warning',
error: 'text-error',
},
FoLink: {
FoHeading: textClasses,
FoLink: {
neutral: 'link-neutral',
primary: 'link-primary',
secondary: 'link-secondary',
Expand All @@ -92,17 +94,9 @@ export function useColor(
warning: 'bg-warning/30',
error: 'bg-error/30',
},
FoLoading: {
neutral: 'text-neutral',
primary: 'text-primary',
secondary: 'text-secondary',
accent: 'text-accent',
info: 'text-info',
success: 'text-success',
warning: 'text-warning',
error: 'text-error',
},
FoRadio: {
FoLoading: textClasses,
FoRadialProgress: textClasses,
FoRadio: {
neutral: '',
primary: 'radio-primary',
secondary: 'radio-secondary',
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/Lib/UseColor/Types/Color.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export type ColorableComponentName = Extract<
| 'FoCheckbox'
| 'FoDivider'
| 'FoModal'
| 'FoRadialProgress'
| 'FoRadio'
| 'FoRange'
| 'FoStatus'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@ import type {
LoadingProps,
MenuProps,
} from '@/UI/Components';
import type { AlertProps } from '@/UI/Components/Alert';
import type { AvatarProps } from '@/UI/Components/Avatar';
import type { AlertProps } from '@/UI/Components/Alert';
import type { AvatarProps } from '@/UI/Components/Avatar';
import type {
RadialProgressBackgroundProps,
RadialProgressProps,
} from '@/UI/Components/RadialProgress';
import type { StatusProps } from '@/UI/Components/Status';
import type { HeadingProps, KeyboardProps, LinkProps } from '@/UI/Content';
import type { DividerProps } from '@/UI/Content/Divider';
Expand Down Expand Up @@ -113,24 +117,24 @@ export interface ConfigurableComponentProps {
& HorizontalPositionComponentConfig<HorizontalPositionGlobalConfig>
& LabelTypeComponentConfig
>;
FoKeyboard: ConfigurableProps<KeyboardProps>;
FoKeyboard: ConfigurableProps<KeyboardProps>;
/** Link defaults */
FoLink: ConfigurableProps<LinkProps>;
FoLink: ConfigurableProps<LinkProps>;
/** Loading defaults */
FoLoading: ConfigurableProps<LoadingProps>;
FoLoading: ConfigurableProps<LoadingProps>;
/** Menu defaults */
FoMenu: ConfigurableProps<MenuProps>;
FoModal: ConfigurableProps<Omit<ModalProps, 'backdrop'> & Colorable>;
/** Radio defaults */
FoRadio: ConfigurableProps<ButtonProps>; // todo: temporary
FoRange: ConfigurableProps<RangeProps>;
FoMenu: ConfigurableProps<MenuProps>;
FoModal: ConfigurableProps<Omit<ModalProps, 'backdrop'> & Colorable>;
FoRadialProgress: ConfigurableProps<RadialProgressProps & RadialProgressBackgroundProps>;
FoRadio: ConfigurableProps<ButtonProps>; // todo: temporary
FoRange: ConfigurableProps<RangeProps>;
/** Select defaults */
FoSelect: ConfigurableProps<SelectProps> & LabelTypeComponentConfig & HorizontalPositionComponentConfig<HorizontalHelperTextPositionConfig>;
FoStatus: ConfigurableProps<StatusProps>;
FoSwitch: ConfigurableProps<SwitchProps> & HorizontalPositionComponentConfig<HorizontalIconPositionConfig>;
FoSelect: ConfigurableProps<SelectProps> & LabelTypeComponentConfig & HorizontalPositionComponentConfig<HorizontalHelperTextPositionConfig>;
FoStatus: ConfigurableProps<StatusProps>;
FoSwitch: ConfigurableProps<SwitchProps> & HorizontalPositionComponentConfig<HorizontalIconPositionConfig>;
/** Table defaults */
FoTable: ConfigurableProps<TableProps>;
FoTabs: ConfigurableProps<TabsProps<TabProps>>;
FoTable: ConfigurableProps<TableProps>;
FoTabs: ConfigurableProps<TabsProps<TabProps>>;
FoTextarea: ConfigurableProps<
TextareaProps
& HorizontalPositionComponentConfig<HorizontalPositionGlobalConfig>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import type { Colorable, Preset, Presettable } from '@/Lib';

export type RadialProgressBackgroundPreset = Extract<Preset, 'solid' | 'soft'>;

export type RadialProgressBackgroundProps = Colorable & Presettable<RadialProgressBackgroundPreset>;

export interface RadialProgressProps extends Colorable {
/** The progress' value */
value: number;

/** The progress' background style, if this is set, the color prop will be ignored */
background?: RadialProgressBackgroundProps;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from '@/UI/Components/RadialProgress/Types/RadialProgress';
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<template>
<div class="radial-progress"
:class="background === undefined ? colorClass : backgroundClass"
:style="`--value:${value};`"
role="progressbar"
:aria-valuenow="value"
>
<slot />
</div>
</template>

<script setup lang="ts">
import type { Color, ComponentName, Preset } from '@/Lib';
import type { RadialProgressProps } from '@/UI/Components/RadialProgress';
import { useFlyonUIVueAppConfig } from '@/Lib';
import { useColor } from '@/Lib/UseColor/Internal';
import { useFlyonUIVueAppConfigProperty } from '@/Lib/UseFlyonUIVueAppConfig/Internal';
import { computed } from 'vue';

const props = defineProps<RadialProgressProps>();

const componentName: ComponentName = 'FoRadialProgress';
const { config } = useFlyonUIVueAppConfig();

const colorClass = useColor(config, componentName, () => props.color);

const backgroundClass = computed((): string => {
const emptyColorClasses: Record<Color, ''> = {
neutral: '',
primary: '',
secondary: '',
accent: '',
info: '',
success: '',
warning: '',
error: '',
};

const colorClasses: Record<Preset, Record<Color, string>> = {
solid: {
neutral: 'bg-neutral text-neutral-content border-4 border-transparent',
primary: 'bg-primary text-primary-content border-4 border-transparent',
secondary: 'bg-secondary text-secondary-content border-4 border-transparent',
accent: 'bg-accent text-accent-content border-4 border-transparent',
info: 'bg-info text-info-content border-4 border-transparent',
success: 'bg-success text-success-content border-4 border-transparent',
warning: 'bg-warning text-warning-content border-4 border-transparent',
error: 'bg-error text-error-content border-4 border-transparent',
},
outline: emptyColorClasses,
dash: emptyColorClasses,
soft: {
neutral: 'bg-neutral/10 text-neutral border-4 border-transparent',
primary: 'bg-primary/10 text-primary border-4 border-transparent',
secondary: 'bg-secondary/10 text-secondary border-4 border-transparent',
accent: 'bg-accent/10 text-accent border-4 border-transparent',
info: 'bg-info/10 text-info border-4 border-transparent',
success: 'bg-success/10 text-success border-4 border-transparent',
warning: 'bg-warning/10 text-warning border-4 border-transparent',
error: 'bg-error/10 text-error border-4 border-transparent',
},
gradient: emptyColorClasses,
text: emptyColorClasses,
dot: emptyColorClasses,
};

const defaultPreset = useFlyonUIVueAppConfigProperty(config, componentName, 'preset', props.background?.preset).value;
const defaultColor = useFlyonUIVueAppConfigProperty(config, componentName, 'color', props.background?.color).value;

return colorClasses[defaultPreset][defaultColor];
});
</script>
1 change: 1 addition & 0 deletions packages/core/src/UI/Components/RadialProgress/UI/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as FoRadialProgress } from '@/UI/Components/RadialProgress/UI/FoRadialProgress.vue';
2 changes: 2 additions & 0 deletions packages/core/src/UI/Components/RadialProgress/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from '@/UI/Components/RadialProgress/Types';
export * from '@/UI/Components/RadialProgress/UI';
2 changes: 1 addition & 1 deletion packages/core/src/UI/Components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ export * from '@/UI/Components/ListGroup';
export * from '@/UI/Components/Loading';
export * from '@/UI/Components/Menu';
export * from '@/UI/Components/Navbar';
export * from '@/UI/Components/RadialProgress';
export * from '@/UI/Components/Skeleton';
export * from '@/UI/Components/Stats';
export * from '@/UI/Components/Status';
export * from '@/UI/Components/Swap';

export * from '@/UI/Components/ThemeController';
// export * from '@/Components/Radio';
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,13 @@ export function useSidebarItems(): ComputedRef<SidebarItem[]> {
icon: 'line-md:loading-twotone-loop',
children: [],
},
{
text: 'Radial Progress',
to: `${flyonUIVueNextPath}/components/radial-progress`,
icon: 'tabler:progress',
children: [],
badge: _unreleasedBadge,
},
{
text: 'Skeleton',
to: `${flyonUIVueNextPath}/components/skeleton`,
Expand Down
2 changes: 2 additions & 0 deletions packages/docs/.vitepress/theme/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import TabsDocs from '@/Navigations/Tabs/T
import AlertDocs from '@/Next/Components/Alert/AlertDocs.vue';
import AvatarDocs from '@/Next/Components/Avatar/AvatarDocs.vue';
import DiffDocs from '@/Next/Components/Diff/DiffDocs.vue';
import RadialProgressDocs from '@/Next/Components/RadialProgress/RadialProgressDocs.vue';
import SkeletonDocs from '@/Next/Components/Skeleton/SkeletonDocs.vue';
import StatusDocs from '@/Next/Components/Status/StatusDocs.vue';
import BlockQuoteDocs from '@/Next/Content/BlockQuote/BlockQuoteDocs.vue';
Expand Down Expand Up @@ -111,6 +112,7 @@ export default {
{ name: 'PaginationDocs', instance: PaginationDocs },
{ name: 'PopoverDocs', instance: PopoverDocs },
{ name: 'RangeDocs', instance: RangeDocs },
{ name: 'RadialProgressDocs', instance: RadialProgressDocs },
{ name: 'SkeletonDocs', instance: SkeletonDocs },
{ name: 'StatsDocs', instance: StatsDocs },
{ name: 'StatusDocs', instance: StatusDocs },
Expand Down
2 changes: 1 addition & 1 deletion packages/docs/Next/Components/Avatar.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

<AvatarDocs section="initials-placeholder" />

## Variants
## Presets

### Solid

Expand Down
47 changes: 47 additions & 0 deletions packages/docs/Next/Components/RadialProgress.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Radial Progress

## Variants

### Default

<RadialProgressDocs section="default" />

### With values

<RadialProgressDocs section="with-value" />

### With text

<RadialProgressDocs section="with-text" />

## Colors

### Solid

<RadialProgressDocs section="color" />

## Background

### Color

<RadialProgressDocs section="background-color" />

### Soft

<RadialProgressDocs section="soft-background" />

## Sizes

### Custom size & thickness

<RadialProgressDocs section="custom-size-and-thickness" />

## Api

### Props

<RadialProgressDocs section="props" />

### Slots

<RadialProgressDocs section="slots" />
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<template>
<FoRadialProgress color="neutral"
:value="70"
style="--size:12rem; --thickness: 2px;"
>
70%
</FoRadialProgress>

<FoRadialProgress color="neutral"
:value="70"
style="--size:12rem; --thickness: 2rem;"
>
70%
</FoRadialProgress>

<FoRadialProgress color="primary"
:value="70"
style="--size:12rem; --thickness: 1rem;"
>
70%
</FoRadialProgress>
</template>

<script setup lang="ts">
import { FoRadialProgress } from 'flyonui-vue';
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<template>
<FoRadialProgress :value="75" />
</template>

<script setup lang="ts">
import { FoRadialProgress } from 'flyonui-vue';
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<template>
<FoRadialProgress :value="70">
70%
</FoRadialProgress>

<FoRadialProgress :background="{ color: 'primary' }"
:value="70"
>
70%
</FoRadialProgress>

<FoRadialProgress :background="{ color: 'secondary' }"
:value="70"
>
70%
</FoRadialProgress>

<FoRadialProgress :background="{ color: 'accent' }"
:value="70"
>
70%
</FoRadialProgress>

<FoRadialProgress :background="{ color: 'info' }"
:value="70"
>
70%
</FoRadialProgress>

<FoRadialProgress :background="{ color: 'success' }"
:value="70"
>
70%
</FoRadialProgress>

<FoRadialProgress :background="{ color: 'warning' }"
:value="70"
>
70%
</FoRadialProgress>

<FoRadialProgress :background="{ color: 'error' }"
:value="70"
>
70%
</FoRadialProgress>
</template>

<script setup lang="ts">
import { FoRadialProgress } from 'flyonui-vue';
</script>
Loading