Skip to content

Commit

Permalink
feat: add optionalContent prop
Browse files Browse the repository at this point in the history
  • Loading branch information
wmui51 committed Jun 4, 2023
1 parent 9e83bba commit 7bc7974
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/tile/src/Tile.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const Tile = (props) => {
disabled,
divider,
media,
optionalContent,
orientation = "vertical",
selected,
statusBadge,
Expand Down Expand Up @@ -64,6 +65,7 @@ const Tile = (props) => {
hasHover={hasHover}
isPressed={isPressed}
media={media}
optionalContent={optionalContent}
orientation={orientation}
selected={selected}
statusBadge={statusBadge}
Expand Down Expand Up @@ -100,6 +102,8 @@ Tile.propTypes = {
divider: PropTypes.bool,
/** The media associated with the Tile */
media: PropTypes.node.isRequired,
/** Pass in the additional components for the complex variation */
optionalContent: PropTypes.node,
/** Sets the orientation of the Tile */
orientation: PropTypes.oneOf(AVAILABLE_ORIENTATIONS),
/** Sets the selected state of the Tile */
Expand Down
16 changes: 16 additions & 0 deletions packages/tile/src/presenters/TilePresenter.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const TilePresenter = (props) => {
hasHover,
isPressed,
media,
optionalContent,
orientation,
selected,
statusBadge,
Expand Down Expand Up @@ -58,6 +59,10 @@ const TilePresenter = (props) => {
);
const titleClassName = createCustomClassNames(className, "title");
const subtitleClassName = createCustomClassNames(className, "subtitle");
const optionalContentClassName = createCustomClassNames(
className,
"optional-content-container"
);

return (
<ThemeContext.Consumer>
Expand Down Expand Up @@ -135,6 +140,16 @@ const TilePresenter = (props) => {
>
{subtitle}
</div>
{optionalContent && (
<div
className={cx([
optionalContentClassName,
css(styles.higTileOptionContentContainer),
])}
>
{optionalContent}
</div>
)}
</div>
</div>
);
Expand All @@ -152,6 +167,7 @@ TilePresenter.propTypes = {
hasHover: PropTypes.bool,
isPressed: PropTypes.bool,
media: PropTypes.node,
optionalContent: PropTypes.node,
orientation: PropTypes.oneOf(AVAILABLE_ORIENTATIONS),
selected: PropTypes.bool,
statusBadge: PropTypes.node,
Expand Down
4 changes: 4 additions & 0 deletions packages/tile/src/presenters/stylesheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,10 @@ export default function stylesheet(props, themeData, themeMeta) {
top: `-${themeData["tile.haloWidth"]}`,
zIndex: 2,
},
higTileOptionContentContainer: {
fontSize: themeData["density.fontSizes.small"],
marginBottom: themeData["density.spacings.extraSmall"],
},
};

return customStylesheet
Expand Down

0 comments on commit 7bc7974

Please sign in to comment.