InfoPanel: indicate lack of support for duotone weight in JS lib

While phosphor-icons uses an icon font implementation, we won't be able
to provide the duotone weight in that library. We now indicate lack of
support by disabling the code snippet and copy button.
This commit is contained in:
rektdeckard
2020-09-27 13:47:49 -04:00
parent 996229580a
commit 3fdc7bb87a
2 changed files with 36 additions and 23 deletions

View File

@@ -121,6 +121,10 @@
cursor: pointer; cursor: pointer;
} }
.snippet button:disabled {
cursor: not-allowed;
}
.button-row { .button-row {
display: flex; display: flex;
} }

View File

@@ -45,7 +45,10 @@ const InfoPanel: React.FC<InfoPanelProps> = (props) => {
const ref = useRef<SVGSVGElement>(null); const ref = useRef<SVGSVGElement>(null);
const snippets = { const snippets = {
html: `<i class="ph-${name}${ html:
weight === "duotone"
? "This weight is not yet supported"
: `<i class="ph-${name}${
weight === "regular" ? "" : `-${weight}` weight === "regular" ? "" : `-${weight}`
}"></i>`, }"></i>`,
react: `<${Icon.displayName} size={${size}} ${ react: `<${Icon.displayName} size={${size}} ${
@@ -53,7 +56,7 @@ const InfoPanel: React.FC<InfoPanelProps> = (props) => {
}${weight === "regular" ? "" : `weight="${weight}" `}/>`, }${weight === "regular" ? "" : `weight="${weight}" `}/>`,
vue: `<Ph${Icon.displayName} :size="${size}" ${ vue: `<Ph${Icon.displayName} :size="${size}" ${
color !== "#000000" ? `color="${color}" ` : "" color !== "#000000" ? `color="${color}" ` : ""
}${weight === "regular" ? "" : `weight="${weight}" `}/>` }${weight === "regular" ? "" : `weight="${weight}" `}/>`,
}; };
const handleCopySnippet = ( const handleCopySnippet = (
@@ -101,22 +104,6 @@ const InfoPanel: React.FC<InfoPanelProps> = (props) => {
</div> </div>
</div> </div>
<div className="icon-usage"> <div className="icon-usage">
<div className="snippet">
HTML/CSS
<pre tabIndex={0}>
{snippets.html}
<button
title="Copy snippet"
onClick={(e) => handleCopySnippet(e, "html")}
>
{copied === "html" ? (
<CheckCircle size={24} color="#1FA647" weight="fill" />
) : (
<Copy size={24} color="currentColor" weight="fill" />
)}
</button>
</pre>
</div>
<div className="snippet"> <div className="snippet">
React React
<pre tabIndex={0}> <pre tabIndex={0}>
@@ -149,13 +136,33 @@ const InfoPanel: React.FC<InfoPanelProps> = (props) => {
</button> </button>
</pre> </pre>
</div> </div>
<div className="snippet">
HTML/CSS
<pre
tabIndex={0}
style={weight === "duotone" ? { color: "#B7B7B7" } : {}}
>
{snippets.html}
<button
title="Copy snippet"
onClick={(e) => handleCopySnippet(e, "html")}
disabled={weight === "duotone"}
>
{copied === "html" ? (
<CheckCircle size={24} color="#1FA647" weight="fill" />
) : (
<Copy size={24} color="currentColor" weight="fill" />
)}
</button>
</pre>
</div>
<div className="button-row"> <div className="button-row">
<button <button
style={{ color: isDark ? "white" : "black" }} style={{ color: isDark ? "white" : "black" }}
onClick={handleDownloadSVG} onClick={handleDownloadSVG}
> >
<Download size={32} color="currentColor" weight="fill" />{" "} <Download size={32} color="currentColor" weight="fill" /> Download
Download SVG SVG
</button> </button>
<button <button
style={{ color: isDark ? "white" : "black" }} style={{ color: isDark ? "white" : "black" }}
@@ -177,7 +184,9 @@ const InfoPanel: React.FC<InfoPanelProps> = (props) => {
size={32} size={32}
weight="fill" weight="fill"
onClick={() => setOpen(false)} onClick={() => setOpen(false)}
onKeyDown={(e) => {e.key === "Enter" && setOpen(false)}} onKeyDown={(e) => {
e.key === "Enter" && setOpen(false);
}}
/> />
</motion.section> </motion.section>
); );