Skip to content

Commit

Permalink
feat(buttons): m3 appearance tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
nolimits4web committed Aug 8, 2022
1 parent f5f1fb4 commit 929ec8e
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/react/components/ListButton.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const ListButton = forwardRef((props, ref) => {
};

const c = themeClasses(
ListButtonClasses({ ...props, hairlines }, colors, className),
ListButtonClasses({ ...props, hairlines }, colors, className, theme),
className
);

Expand Down
1 change: 1 addition & 0 deletions src/react/components/ListItem.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ const ListItem = forwardRef((props, ref) => {
},
colors,
{
theme,
textColor,
needsTouchRipple,
isMenuListItemActive,
Expand Down
15 changes: 11 additions & 4 deletions src/shared/classes/ButtonClasses.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,17 @@ export const ButtonClasses = (props, colors, classes, darkClasses) => {
ios: `uppercase duration-100 font-semibold`,
material: `duration-300 font-medium`,

square:
segmented && !segmentedStrong
? 'first:rounded-l last:rounded-r'
: 'rounded',
square: {
ios:
segmented && !segmentedStrong
? 'first:rounded-l last:rounded-r'
: 'rounded',
material:
segmented && !segmentedStrong
? 'first:rounded-lg-l last:rounded-lg-r'
: 'rounded-lg',
},

rounded: segmented && !segmentedStrong ? '' : 'rounded-full',
},
style: {
Expand Down
6 changes: 5 additions & 1 deletion src/svelte/components/ListButton.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import { useThemeClasses } from '../shared/use-theme-classes.js';
import { useTouchRipple } from '../shared/use-touch-ripple.js';
import { ListButtonClasses } from '../../shared/classes/ListButtonClasses.js';
import { useTheme } from '../shared/use-theme.js';
let className = undefined;
export { className as class };
Expand All @@ -28,6 +29,9 @@
const rippleEl = { current: null };
let theme;
theme = useTheme({ ios, material }, (v) => (theme = v));
$: useTouchRipple(rippleEl, touchRipple);
$: colors = {
Expand All @@ -39,7 +43,7 @@
$: c = useThemeClasses(
{ ios, material },
ListButtonClasses({ hairlines }, colors, className),
ListButtonClasses({ hairlines }, colors, className, theme),
className,
(v) => (c = v)
);
Expand Down
1 change: 1 addition & 0 deletions src/svelte/components/ListItem.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@
},
colors,
{
theme,
textColor,
needsTouchRipple,
isMenuListItemActive,
Expand Down
5 changes: 4 additions & 1 deletion src/vue/components/ListButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<script>
import { ref, computed } from 'vue';
import { ListButtonClasses } from '../../shared/classes/ListButtonClasses.js';
import { useTheme } from '../shared/use-theme.js';
import { useThemeClasses } from '../shared/use-theme-classes.js';
import { useTouchRipple } from '../shared/use-touch-ripple.js';
Expand Down Expand Up @@ -60,8 +61,10 @@
...(props.colors || {}),
}));
const theme = useTheme(props);
const c = useThemeClasses(props, () =>
ListButtonClasses(props, colors.value, ctx.attrs.class)
ListButtonClasses(props, colors.value, ctx.attrs.class, theme.value)
);
const isLink = computed(() => !!props.href || props.href === '');
Expand Down
1 change: 1 addition & 0 deletions src/vue/components/ListItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@
const c = useThemeClasses(props, () =>
ListItemClasses(props, colors.value, {
theme: theme.value,
textColor: textColor.value,
needsTouchRipple: needsTouchRipple.value,
isMenuListItemActive: isMenuListItemActive.value,
Expand Down

0 comments on commit 929ec8e

Please sign in to comment.