Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added documentation of how to use SVG Strings as custom icon. #6303

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions components/doc/customicons/svgstringdoc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { DocSectionCode } from '@/components/doc/common/docsectioncode';
import { DocSectionText } from '@/components/doc/common/docsectiontext';

export function SVGStringDoc(props) {
const code = {
basic: `
const svgMarkupString = "<svg xmlns=\\"http:\\/\\/www.w3.org\\/2000\\/svg\\" width=\\"24\\" height=\\"24\\" viewBox=\\"0 0 24 24\\" >
<g id=\\"chevron-down\\">
<path d=\\"M12,15.25a.74.74,0,0,1-.53-.22l-5-5A.75.75,0,0,1,7.53,9L12,13.44,16.47,9A.75.75,0,0,1,17.53,10l-5,5A.74.74,0,0,1,12,15.25Z\\" \\/>
<\\/g>
<\\/svg>";

<Dropdown dropdownIcon={(options) =>
<span dangerouslySetInnerHTML={{ __html: svgMarkupString }} {...options.iconProps} />
} />
`
};

return (
<>
<DocSectionText {...props}>
<p>SVG markup strings can also be embedded as icons by using "i" or "span" tags.</p>
</DocSectionText>
<DocSectionCode code={code} hideToggleCode import hideStackBlitz />
</>
);
}
6 changes: 6 additions & 0 deletions pages/customicons/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { FontAwesomeDoc } from '@/components/doc/customicons/fontawesomedoc';
import { ImageDoc } from '@/components/doc/customicons/imagedoc';
import { MaterialDoc } from '@/components/doc/customicons/materialdoc';
import { SVGDoc } from '@/components/doc/customicons/svgdoc';
import { SVGStringDoc } from '@/components/doc/customicons/svgstringdoc';

const ContextMenuDemo = () => {
const docs = [
Expand All @@ -21,6 +22,11 @@ const ContextMenuDemo = () => {
label: 'SVG',
component: SVGDoc
},
{
id: 'svgstring',
label: 'SVG String',
component: SVGStringDoc
},
{
id: 'image',
label: 'Image',
Expand Down
Loading