Skip to content

Commit d45f466

Browse files
ryanomackeyemyarodandreancardona
authored
feat(Tile): add optional expand/collapse labels for chevron (#7199)
* feat(Tile): add optional expand/collapse labels for chevron * Update packages/react/src/components/Tile/Tile.js Co-authored-by: emyarod <emyarod@users.noreply.github.com> * fix(Tile): remove default props * style(Tile): adjust positioning of chevron * test(Tile): update PublicAPI snapshot * style(Tile): remove flex-direction property Co-authored-by: emyarod <emyarod@users.noreply.github.com> Co-authored-by: Andrea N. Cardona <andreancardona@gmail.com>
1 parent da821e3 commit d45f466

File tree

4 files changed

+28
-4
lines changed

4 files changed

+28
-4
lines changed

packages/components/src/components/tile/_tile.scss

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,14 @@
105105

106106
.#{$prefix}--tile__chevron {
107107
position: absolute;
108-
right: 0.5rem;
109-
bottom: 0.5rem;
108+
right: $carbon--spacing-05;
109+
bottom: $carbon--spacing-05;
110+
display: flex;
111+
align-items: flex-end;
110112
height: 1rem;
111113

112114
svg {
115+
margin-left: $carbon--spacing-03;
113116
transform-origin: center;
114117
transition: $duration--fast-02 motion(standard, productive);
115118
fill: $ui-05;

packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5748,9 +5748,15 @@ Map {
57485748
"tileCollapsedIconText": Object {
57495749
"type": "string",
57505750
},
5751+
"tileCollapsedLabel": Object {
5752+
"type": "string",
5753+
},
57515754
"tileExpandedIconText": Object {
57525755
"type": "string",
57535756
},
5757+
"tileExpandedLabel": Object {
5758+
"type": "string",
5759+
},
57545760
},
57555761
},
57565762
"TileAboveTheFoldContent" => Object {

packages/react/src/components/Tile/Tile-story.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ const props = {
7373
'Collapsed icon text (tileExpandedIconText)',
7474
'Interact to Collapse tile'
7575
),
76+
tileCollapsedLabel: text('Collapsed icon text (tileCollapsedLabel)'),
77+
tileExpandedLabel: text('Collapsed icon text (tileExpandedLabel)'),
7678
handleClick: action('handleClick'),
7779
light: boolean('Light variant (light)', false),
7880
}),

packages/react/src/components/Tile/Tile.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -428,10 +428,20 @@ export class ExpandableTile extends Component {
428428
*/
429429
tileCollapsedIconText: PropTypes.string,
430430

431+
/**
432+
* When "collapsed", a label to appear next to the chevron (e.g., "View more").
433+
*/
434+
tileCollapsedLabel: PropTypes.string,
435+
431436
/**
432437
* The description of the "expanded" icon that can be read by screen readers.
433438
*/
434439
tileExpandedIconText: PropTypes.string,
440+
441+
/**
442+
* When "expanded", a label to appear next to the chevron (e.g., "View less").
443+
*/
444+
tileExpandedLabel: PropTypes.string,
435445
};
436446

437447
static defaultProps = {
@@ -546,8 +556,10 @@ export class ExpandableTile extends Component {
546556
tileMaxHeight, // eslint-disable-line
547557
tilePadding, // eslint-disable-line
548558
handleClick, // eslint-disable-line
549-
tileCollapsedIconText, // eslint-disable-line
550-
tileExpandedIconText, // eslint-disable-line
559+
tileCollapsedIconText,
560+
tileExpandedIconText,
561+
tileCollapsedLabel,
562+
tileExpandedLabel,
551563
onBeforeClick, // eslint-disable-line
552564
light,
553565
...other
@@ -599,6 +611,7 @@ export class ExpandableTile extends Component {
599611
{childrenAsArray[0]}
600612
</div>
601613
<div className={`${prefix}--tile__chevron`}>
614+
<span>{isExpanded ? tileExpandedLabel : tileCollapsedLabel}</span>
602615
<ChevronDown16 />
603616
</div>
604617
<div className={`${prefix}--tile-content`}>{childrenAsArray[1]}</div>

0 commit comments

Comments
 (0)