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
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import type { Color, Colorable, ConfigurableComponentName, Preset, Shape, Size }
import type { PickIfExists, Prettify } from '@/Lib/Utils/Internal';
import type { Direction, HorizontalPosition } from '@/Types';
import type {
AvatarPlaceholderProps,
BadgeProps,
ButtonProps,
LabelType,
Expand All @@ -12,7 +11,6 @@ import type {
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';
Expand Down Expand Up @@ -104,7 +102,7 @@ type ConfigurableProps<MaybeProps extends object> = Prettify<
/** Configurable props for each component */
export interface ConfigurableComponentProps {
FoAlert: ConfigurableProps<AlertProps>;
FoAvatar: ConfigurableProps<AvatarProps & AvatarPlaceholderProps>;
FoAvatar: ConfigurableProps<AvatarProps>;
/** Badge defaults */
FoBadge: ConfigurableProps<BadgeProps & HorizontalPositionComponentConfig<HorizontalIconPositionConfig>>;
/** Button defaults */
Expand Down Expand Up @@ -132,7 +130,7 @@ export interface ConfigurableComponentProps {
/** Menu defaults */
FoMenu: ConfigurableProps<MenuProps>;
FoModal: ConfigurableProps<Omit<ModalProps, 'backdrop'> & Colorable>;
FoRadialProgress: ConfigurableProps<RadialProgressProps & RadialProgressBackgroundProps>;
FoRadialProgress: ConfigurableProps<RadialProgressProps>;
FoRadio: ConfigurableProps<RadioProps>;
FoRange: ConfigurableProps<RangeProps>;
/** Select defaults */
Expand Down
28 changes: 5 additions & 23 deletions packages/core/src/UI/Components/Avatar/UI/FoAvatar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,11 @@
</template>

<script setup lang="ts">
import type { Color, ComponentName, Preset, Size } from '@/Lib';
import type { Color, ComponentName, Size } from '@/Lib';
import type {
AvatarIndicatorPlacement,
AvatarIndicatorStatus,
AvatarPlaceholderPreset,
AvatarProps,
} from '@/UI/Components/Avatar';
import type { Slot } from 'vue';
Expand Down Expand Up @@ -69,18 +70,7 @@ const [
];

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

const classes: Record<Preset, Record<Color, string>> = {
const classes: Record<AvatarPlaceholderPreset, Record<Color, string>> = {
solid: {
neutral: 'bg-neutral text-neutral-content',
primary: 'bg-primary text-primary-content',
Expand All @@ -101,7 +91,6 @@ const presetAndColorClass = computed((): string => {
warning: 'border border-warning text-warning',
error: 'border border-error text-error',
},
dash: emptyColorClasses,
soft: {
neutral: 'bg-neutral/10 text-neutral',
primary: 'bg-primary/10 text-primary',
Expand All @@ -112,22 +101,15 @@ const presetAndColorClass = computed((): string => {
warning: 'bg-warning/10 text-warning',
error: 'bg-error/10 text-error',
},
gradient: emptyColorClasses,
text: emptyColorClasses,
dot: emptyColorClasses,
};

const defaultPreset = 'src' in props.avatar
? null
: useFlyonUIVueAppConfigProperty(config, componentName, 'preset', props.avatar?.preset).value;
const defaultPreset = 'src' in props.avatar ? null : props.avatar.preset ?? 'solid';

if (defaultPreset === null) {
return '';
}

const defaultColor = 'src' in props.avatar
? null
: useFlyonUIVueAppConfigProperty(config, componentName, 'color', props.avatar.color).value;
const defaultColor = 'src' in props.avatar ? null : props.avatar.color ?? 'neutral';

if (defaultColor === null) {
return '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@
</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';
import type { Color, ComponentName } from '@/Lib';
import type { RadialProgressBackgroundPreset, RadialProgressProps } from '@/UI/Components/RadialProgress';
import { useFlyonUIVueAppConfig } from '@/Lib';
import { useColor } from '@/Lib/UseColor/Internal';
import { computed } from 'vue';

const props = defineProps<RadialProgressProps>();

Expand All @@ -25,18 +24,7 @@ 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>> = {
const colorClasses: Record<RadialProgressBackgroundPreset, Record<Color, string>> = {
solid: {
neutral: 'bg-neutral text-neutral-content border-4 border-transparent',
primary: 'bg-primary text-primary-content border-4 border-transparent',
Expand All @@ -47,9 +35,7 @@ const backgroundClass = computed((): string => {
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: {
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',
Expand All @@ -59,14 +45,8 @@ const backgroundClass = computed((): string => {
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];
return colorClasses[props.background?.preset ?? 'solid'][props.background?.color ?? 'neutral'];
});
</script>