-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
ref(container) add ellipsis support #105956
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,6 +22,13 @@ import { | |
|
|
||
| /* eslint-disable typescript-sort-keys/interface */ | ||
| interface ContainerLayoutProps { | ||
| /** | ||
| * When true, overflow is set to hidden, text-overflow is set to ellipsis, and white-space is set to nowrap. | ||
| * Individual properties can be overridden by setting the corresponding property (e.g. overflow, text-overflow, white-space). | ||
| * @default undefined | ||
| */ | ||
| ellipsis?: Responsive<boolean>; | ||
|
|
||
| background?: Responsive<SurfaceVariant>; | ||
| display?: Responsive< | ||
| | 'block' | ||
|
|
@@ -82,6 +89,9 @@ interface ContainerLayoutProps { | |
| alignSelf?: Responsive<React.CSSProperties['alignSelf']>; | ||
| justifySelf?: Responsive<React.CSSProperties['justifySelf']>; | ||
|
|
||
| textOverflow?: Responsive<React.CSSProperties['textOverflow']>; | ||
| whiteSpace?: Responsive<React.CSSProperties['whiteSpace']>; | ||
|
|
||
| /** | ||
| * Prefer using Flex or Grid gap as opposed to margin. | ||
| * @deprecated | ||
|
|
@@ -167,6 +177,7 @@ const omitContainerProps = new Set<keyof ContainerLayoutProps | 'as'>([ | |
| 'bottom', | ||
| 'column', | ||
| 'display', | ||
| 'ellipsis', | ||
| 'flex', | ||
| 'flexBasis', | ||
| 'flexGrow', | ||
|
|
@@ -197,8 +208,10 @@ const omitContainerProps = new Set<keyof ContainerLayoutProps | 'as'>([ | |
| 'radius', | ||
| 'right', | ||
| 'row', | ||
| 'textOverflow', | ||
| 'top', | ||
| 'width', | ||
| 'whiteSpace', | ||
| ]); | ||
|
|
||
| export const Container = styled( | ||
|
|
@@ -277,6 +290,19 @@ export const Container = styled( | |
| ${p => rc('border-left', p.borderLeft, p.theme, getBorder)}; | ||
| ${p => rc('border-right', p.borderRight, p.theme, getBorder)}; | ||
|
|
||
| ${p => | ||
| rc( | ||
| 'text-overflow', | ||
| p.textOverflow ? p.textOverflow : p.ellipsis ? 'ellipsis' : undefined, | ||
| p.theme | ||
| )}; | ||
| ${p => | ||
| rc( | ||
| 'white-space', | ||
| p.whiteSpace ? p.whiteSpace : p.ellipsis ? 'nowrap' : undefined, | ||
| p.theme | ||
| )}; | ||
cursor[bot] marked this conversation as resolved.
Show resolved
Hide resolved
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Responsive ellipsis values not correctly mapped to CSSMedium Severity The
Comment on lines
+299
to
+309
This comment was marked as outdated.
Sorry, something went wrong.
Comment on lines
+303
to
+309
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: The 🔍 Detailed AnalysisWhen the 💡 Suggested FixRefactor the 🤖 Prompt for AI AgentDid we get this right? 👍 / 👎 to inform future reviews. |
||
|
|
||
| /** | ||
| * This cast is required because styled-components does not preserve the generic signature of the wrapped component. | ||
| * By default, the generic type parameter <T> is lost, so we use 'as unknown as' to restore the correct typing. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On
Text, we have this namedwrap:sentry/static/app/components/core/text/text.tsx
Line 139 in 776966b
The more I think about it, the more I would like us to stay as close as possible to html attributes. For example,
<Text bold>isn’t better than settingfont-weightand<Text wrap=“nowrap”>isn’t better than<Text whiteSpace=“nowrap”>, especially if it works differently onContainerand we also have atextWrapprop onText.I sometimes find myself looking at the implementation of our core components just to know which props exist because I can’t find what I’m looking for in auto complete. That’s partially because auto complete lists all html props so it’s not helpful, but also because I type
fontWeightortextDecorationand don’t find anything because our props are named differently ...There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's fair feedback. I think we can pull usage and see if that sticks, or if it's not been a good addition.