Skip to content
Open
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
12 changes: 5 additions & 7 deletions static/app/components/group/inboxBadges/shortId.tsx
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -11,7 +13,9 @@ export function ShortId({shortId, avatar, className}: Props) {
return (
<Wrapper className={className}>
<AvatarWrapper>{avatar}</AvatarWrapper>
<IdWrapper>{shortId}</IdWrapper>
<Text trim="cap" ellipsis variant="inherit">
{shortId}
</Text>
</Wrapper>
);
}
Expand All @@ -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;
`;
2 changes: 1 addition & 1 deletion static/app/oxlint-suppressions.json
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
11 changes: 11 additions & 0 deletions static/packages/scraps/src/text/text.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,17 @@ Handle text overflow with the `ellipsis` prop to truncate long text with an elli
</Text>
```

### 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
<Flex align="center" gap="xs">
<IconIssues size="sm" />
<Text trim="cap">PROJECT-1A</Text>
</Flex>
```

## Wrapping

Use the `textWrap` prop to control how the text wraps, and the `wordBreak` prop to control where the text is split during wrapping.
Expand Down
12 changes: 8 additions & 4 deletions static/packages/scraps/src/text/text.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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};
Expand All @@ -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'};
`;

Expand Down
Loading