diff --git a/static/app/components/group/inboxBadges/shortId.tsx b/static/app/components/group/inboxBadges/shortId.tsx index 322e89ddd369..d60bdb095f71 100644 --- a/static/app/components/group/inboxBadges/shortId.tsx +++ b/static/app/components/group/inboxBadges/shortId.tsx @@ -1,5 +1,7 @@ import styled from '@emotion/styled'; +import {Text} from '@sentry/scraps/text'; + /** * Used in new inbox * Renders the project badge and short name @@ -11,7 +13,9 @@ export function ShortId({shortId, avatar, className}: Props) { return ( {avatar} - {shortId} + + {shortId} + ); } @@ -27,9 +31,3 @@ const AvatarWrapper = styled('div')` margin-right: 3px; flex-shrink: 0; `; - -const IdWrapper = styled('div')` - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; -`; diff --git a/static/app/oxlint-suppressions.json b/static/app/oxlint-suppressions.json index 3a821c52937a..1c3ab1112066 100644 --- a/static/app/oxlint-suppressions.json +++ b/static/app/oxlint-suppressions.json @@ -418,7 +418,7 @@ "@sentry/scraps/prefer-primitives": {"count": 1} }, "components/group/inboxBadges/shortId.tsx": { - "@sentry/scraps/prefer-primitives": {"count": 2} + "@sentry/scraps/prefer-primitives": {"count": 1} }, "components/group/inboxBadges/timesTag.tsx": { "@sentry/scraps/prefer-primitives": {"count": 2} diff --git a/static/packages/scraps/src/text/text.mdx b/static/packages/scraps/src/text/text.mdx index 42de0df74722..d3de694b6941 100644 --- a/static/packages/scraps/src/text/text.mdx +++ b/static/packages/scraps/src/text/text.mdx @@ -245,6 +245,17 @@ Handle text overflow with the `ellipsis` prop to truncate long text with an elli ``` +### All-caps text + +The default trim keeps room for lowercase letters and descenders, so all-caps text like an issue ID sits a little high next to an icon. Pass `trim="cap"` to trim to the cap height and baseline instead. + +```jsx + + + PROJECT-1A + +``` + ## Wrapping Use the `textWrap` prop to control how the text wraps, and the `wordBreak` prop to control where the text is split during wrapping. diff --git a/static/packages/scraps/src/text/text.tsx b/static/packages/scraps/src/text/text.tsx index 4e6ae5c17140..d8bbffc62f96 100644 --- a/static/packages/scraps/src/text/text.tsx +++ b/static/packages/scraps/src/text/text.tsx @@ -75,10 +75,11 @@ export interface BaseTextProps { /** * Trims the text box to the glyph bounds with `text-box-trim`. Set to false when * the content is taller than a line of text, such as a tag or pill, so it isn't - * clipped when combined with `ellipsis`. + * clipped when combined with `ellipsis`. Set to `'cap'` to trim to the cap height + * and baseline instead, which centers all-caps text such as issue IDs next to an icon. * @default true */ - trim?: boolean; + trim?: boolean | 'cap'; /** * Determines how text should be underlined. @@ -242,7 +243,10 @@ export const getTextStyles = (p: TextStyleProps) => css` ] }; - overflow: ${p.ellipsis ? 'hidden' : undefined}; + /* A cap trimmed box would clip anything below the baseline, so only clip sideways. + Unlike hidden, clip doesn't let a flex item shrink, so reset its min-width. */ + overflow: ${p.ellipsis ? (p.trim === 'cap' ? 'clip visible' : 'hidden') : undefined}; + min-width: ${p.ellipsis && p.trim === 'cap' ? 0 : undefined}; text-overflow: ${p.ellipsis ? 'ellipsis' : undefined}; white-space: ${p.wrap ? p.wrap : p.ellipsis ? 'nowrap' : undefined}; text-wrap: ${p.textWrap ?? undefined}; @@ -265,7 +269,7 @@ export const getTextStyles = (p: TextStyleProps) => css` .join(' ')}; text-transform: ${p.uppercase ? 'uppercase' : undefined}; - text-box-edge: text text; + text-box-edge: ${p.trim === 'cap' ? 'cap alphabetic' : 'text text'}; text-box-trim: ${p.trim === false ? 'none' : 'trim-both'}; `;