Skip to content

Commit

Permalink
feat(progressbar): m3 styles
Browse files Browse the repository at this point in the history
  • Loading branch information
nolimits4web committed Aug 11, 2022
1 parent b6ed24e commit 05a210c
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 7 deletions.
5 changes: 3 additions & 2 deletions src/react/components/Progressbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { useRef, forwardRef, useImperativeHandle } from 'react';
import { ProgressbarClasses } from '../../shared/classes/ProgressbarClasses.js';
import { ProgressbarColors } from '../../shared/colors/ProgressbarColors.js';
import { useThemeClasses } from '../shared/use-theme-classes.js';
import { useDarkClasses } from '../shared/use-dark-classes.js';

const Progressbar = forwardRef((props, ref) => {
const {
Expand Down Expand Up @@ -34,8 +35,8 @@ const Progressbar = forwardRef((props, ref) => {
};

const themeClasses = useThemeClasses({ ios, material });

const colors = ProgressbarColors(colorsProp);
const dark = useDarkClasses();
const colors = ProgressbarColors(colorsProp, dark);

const c = themeClasses(ProgressbarClasses(colors), className);

Expand Down
8 changes: 6 additions & 2 deletions src/shared/classes/ProgressbarClasses.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@ export const ProgressbarClasses = (colors) => {
base: {
common: `block h-1 bg-opacity-30 overflow-hidden`,
ios: `bg-black rounded-full`,
material: colors.bg,
material: colors.bgMaterial,
},
inner: {
common: `block duration-200 w-full h-full`,
ios: colors.bgIos,
material: colors.bgMaterial,
},
inner: `block ${colors.bg} duration-200 w-full h-full`,
};
};
3 changes: 2 additions & 1 deletion src/shared/colors/ProgressbarColors.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { cls } from '../cls.js';

export const ProgressbarColors = (colorsProp = {}, dark) => {
return {
bg: 'bg-primary',
bgIos: 'bg-primary',
bgMaterial: cls('bg-md-light-primary', dark('dark:md-dark-primary')),
...colorsProp,
};
};
5 changes: 4 additions & 1 deletion src/svelte/components/Progressbar.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import { ProgressbarClasses } from '../../shared/classes/ProgressbarClasses.js';
import { ProgressbarColors } from '../../shared/colors/ProgressbarColors.js';
import { useThemeClasses } from '../shared/use-theme-classes.js';
import { useDarkClasses } from '../shared/use-dark-classes.js';
let className = undefined;
export { className as class };
Expand All @@ -12,7 +13,9 @@
export let progress = 0;
$: colors = ProgressbarColors(colorsProp);
const dark = useDarkClasses();
$: colors = ProgressbarColors(colorsProp, dark);
$: c = useThemeClasses(
{ ios, material },
Expand Down
5 changes: 4 additions & 1 deletion src/vue/components/Progressbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import { ProgressbarClasses } from '../../shared/classes/ProgressbarClasses.js';
import { ProgressbarColors } from '../../shared/colors/ProgressbarColors.js';
import { useThemeClasses } from '../shared/use-theme-classes.js';
import { useDarkClasses } from '../shared/use-dark-classes.js';
export default {
name: 'k-progressbar',
Expand All @@ -37,7 +38,9 @@
},
},
setup(props) {
const colors = computed(() => ProgressbarColors(props.colors || {}));
const colors = computed(() =>
ProgressbarColors(props.colors || {}, useDarkClasses)
);
const c = useThemeClasses(props, () => ProgressbarClasses(colors.value));
Expand Down

0 comments on commit 05a210c

Please sign in to comment.