Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[joy-ui][Badge] Shouldn't crash when using custom size #39986

Merged
merged 4 commits into from
Jan 4, 2024
Merged
Changes from 2 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
8 changes: 5 additions & 3 deletions packages/mui-joy/src/Badge/Badge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import PropTypes from 'prop-types';
import { OverridableComponent } from '@mui/types';
import { unstable_capitalize as capitalize, usePreviousProps } from '@mui/utils';
import { unstable_composeClasses as composeClasses } from '@mui/base';
import { CSSObject } from '@mui/system';
import styled from '../styles/styled';
import useThemeProps from '../styles/useThemeProps';
import useSlot from '../utils/useSlot';
Expand Down Expand Up @@ -101,11 +102,12 @@ const BadgeBadge = styled('span', {
ownerState.anchorOrigin?.horizontal === 'left' ? 'translateX(-50%)' : 'translateX(50%)';
const transformOriginY = ownerState.anchorOrigin?.vertical === 'top' ? '0%' : '100%';
const transformOriginX = ownerState.anchorOrigin?.horizontal === 'left' ? '0%' : '100%';
const typography =
theme.typography[`body-${({ sm: 'xs', md: 'sm', lg: 'md' } as const)[ownerState.size!]}`];
const typography = theme.typography[
`body-${({ sm: 'xs', md: 'sm', lg: 'md' } as const)[ownerState.size!]}`
] as CSSObject | undefined;
ZeeshanTamboli marked this conversation as resolved.
Show resolved Hide resolved
return {
'--Icon-color': 'currentColor',
'--Icon-fontSize': `calc(1em * ${typography.lineHeight ?? '1'})`,
'--Icon-fontSize': `calc(1em * ${typography?.lineHeight ?? '1'})`,
display: 'inline-flex',
flexWrap: 'wrap',
justifyContent: 'center',
Expand Down
Loading