-
Notifications
You must be signed in to change notification settings - Fork 213
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(feat) O3-4249: Add component to support rendering an icon if it exis…
…ts (#1220)
- Loading branch information
Showing
8 changed files
with
367 additions
and
129 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
26 changes: 26 additions & 0 deletions
26
packages/framework/esm-react-utils/src/RenderIfValueIsTruthy.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import React, { type PropsWithChildren } from 'react'; | ||
|
||
/** | ||
* A really simple component that renders its children if the prop named `value` has a truthy value | ||
* | ||
* @example | ||
* ```tsx | ||
* <RenderIfValueIsTruthy value={variable}> | ||
* <Component value={variable} /> | ||
* </RenderIfValueIsTruthy> | ||
* ```` | ||
* | ||
* @param props.value The value to check whether or not its truthy | ||
* @param props.fallback What to render if the value is not truthy. If not specified, nothing will be rendered | ||
* @param props.children The components to render if the `value` is truthy | ||
*/ | ||
export const RenderIfValueIsTruthy: React.FC<PropsWithChildren<{ value: unknown; fallback?: React.ReactNode }>> = ({ | ||
children, | ||
value, | ||
fallback, | ||
}) => { | ||
if (Boolean(value)) { | ||
return <>{children}</>; | ||
} | ||
return fallback ? <>{fallback}</> : null; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
packages/framework/esm-styleguide/src/pictograms/pictograms.module.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
:global([dir='rtl']) { | ||
.pictogram { | ||
transform: scaleX(-1); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters