Skip to content

Commit

Permalink
fix(Icons): add additional logic to handle glyph-only icons (#2488)
Browse files Browse the repository at this point in the history
Co-authored-by: Andrea N. Cardona <andreancardona@gmail.com>
  • Loading branch information
tw15egan and andreancardona authored Aug 23, 2021
1 parent 441b45b commit 971c234
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/components/SVGLibraries/shared/ActionBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,18 @@ const ActionBar = ({
setIsActionBarVisible,
isActionBarVisible,
isLastCard,
glyphOnly,
}) => {
const { site, type } = useContext(LibraryContext);
const component = `<${
pascalCase(friendlyName) + (type === 'pictogram' ? '' : '32')
} />`;
let suffix;
if (type === 'pictogram') {
suffix = '';
} else if (glyphOnly) {
suffix = 'Glyph';
} else {
suffix = '32';
}
const component = `<${pascalCase(friendlyName) + suffix} />`;
const [copyText, setCopyText] = useState(`Copy ${component}`);
const actionBarRef = useRef();

Expand Down
2 changes: 2 additions & 0 deletions src/components/SVGLibraries/shared/SvgCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const SvgCard = ({ icon, containerIsVisible, isLastCard, ...rest }) => {
const [isActionBarVisible, setIsActionBarVisible] = useState(false);

let { source } = assets[0];
const glyphOnly = assets[0].size === 'glyph' && assets.length <= 1;

if (assets.length > 1) {
source = assets.find(({ size }) => size === 32).source;
Expand Down Expand Up @@ -49,6 +50,7 @@ const SvgCard = ({ icon, containerIsVisible, isLastCard, ...rest }) => {
friendlyName={friendlyName}
isActionBarVisible={isActionBarVisible}
setIsActionBarVisible={setIsActionBarVisible}
glyphOnly={glyphOnly}
/>
</>
)}
Expand Down

1 comment on commit 971c234

@vercel
Copy link

@vercel vercel bot commented on 971c234 Aug 23, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.