Skip to content

Commit

Permalink
Merge 99f35c1 into 6825397
Browse files Browse the repository at this point in the history
  • Loading branch information
shleewhite committed Jun 22, 2022
2 parents 6825397 + 99f35c1 commit c515ed0
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .changeset/odd-pumpkins-count.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@twilio-paste/truncate': patch
'@twilio-paste/core': patch
---

[Truncate] fix alignment when truncate is within another component
6 changes: 4 additions & 2 deletions packages/paste-core/components/truncate/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react';
import * as PropTypes from 'prop-types';
import {Box, BoxProps} from '@twilio-paste/box';

import {Box} from '@twilio-paste/box';
import type {BoxProps} from '@twilio-paste/box';
export interface TruncateProps extends Omit<React.HtmlHTMLAttributes<HTMLSpanElement>, 'color'>, Pick<BoxProps, 'as'> {
children: NonNullable<React.ReactNode>;
title: string;
Expand All @@ -13,6 +13,8 @@ const Truncate = React.forwardRef<HTMLSpanElement, TruncateProps>(({children, ..
{...props}
as="span"
display="inline-block"
verticalAlign="bottom"
textDecoration="inherit"
maxWidth="100%"
overflow="hidden"
ref={ref}
Expand Down
11 changes: 11 additions & 0 deletions packages/paste-core/components/truncate/stories/index.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as React from 'react';
import {Box} from '@twilio-paste/box';
import {Text} from '@twilio-paste/text';
import {Anchor} from '@twilio-paste/anchor';
import {Truncate} from '../src';

// eslint-disable-next-line import/no-default-export
Expand All @@ -18,3 +19,13 @@ export const Default = (): React.ReactNode => {
</Box>
);
};

export const TruncateInAnchor = (): React.ReactNode => {
return (
<Box maxWidth="size20">
<Anchor href="https://paste.twilio.design">
<Truncate title="A very very long anchor to truncate">A very very long anchor to truncate</Truncate>
</Anchor>
</Box>
);
};

0 comments on commit c515ed0

Please sign in to comment.