-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This component has a list of SVG icons which we use in our design
- Loading branch information
Showing
8 changed files
with
321 additions
and
23,547 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import React from "react"; | ||
import styled, { css } from "styled-components"; | ||
import theme from "../../theme"; | ||
import { getViewBox } from "../../utils/svgicons"; | ||
import { getPath } from "../../utils/svgicons"; | ||
|
||
export interface SVGIconProps { | ||
name: string; | ||
color?: "success" | "danger" | "warning" | "notification" | "white"; | ||
size?: "sm" | "md" | "lg" | "xl" | "xxl"; | ||
[x: string]: any; | ||
} | ||
|
||
const StyledSVGIcon = styled.svg<SVGIconProps>` | ||
fill: ${theme.colors.primary}; | ||
width: ${theme.iconSize.md}; | ||
height: ${theme.iconSize.md}; | ||
${({ color }) => | ||
color && | ||
css` | ||
fill: ${theme.colors[color]}; | ||
`} | ||
${({ size }) => | ||
size && | ||
css` | ||
width: ${theme.iconSize[size]}; | ||
height: ${theme.iconSize[size]}; | ||
`} | ||
`; | ||
|
||
export const SVGIcon: React.FC<SVGIconProps> = ({ name, ...props }) => { | ||
const ViewBox = getViewBox(name); | ||
const Path = getPath(name); | ||
|
||
return ( | ||
<StyledSVGIcon | ||
{...props} | ||
viewBox={ViewBox} | ||
xmlns="http://www.w3.org/2000/svg" | ||
xmlnsXlink="http://www.w3.org/1999/xlink" | ||
> | ||
{Path} | ||
</StyledSVGIcon> | ||
); | ||
}; |
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 @@ | ||
export * from "./SVGIcon"; |
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,79 @@ | ||
import { useState } from "react"; | ||
import styled from "styled-components"; | ||
import { Meta, Story, Preview } from "@storybook/addon-docs/blocks"; | ||
import { SVGIcon } from "../components/svgicon"; | ||
import { Container, Flex } from "../components/container"; | ||
|
||
<Meta title="Components/SVGIcon" component={SVGIcon} /> | ||
|
||
# SVGIcon | ||
|
||
## Props | ||
|
||
- `name`: `string` — **required** | ||
- `size`: `string` — **optional**: "sm" | "md" | "lg" | "xl" | "xxl" | ||
- `color`: `string` — **optional**: "success" | "danger" | "warning" | "notification" | "white" | ||
|
||
### Icons Sizes | ||
|
||
<Preview> | ||
<Story name="size"> | ||
<Flex justifyContent="space-evenly"> | ||
<SVGIcon name="dashboard" size="sm" /> | ||
<SVGIcon name="dashboard" /> | ||
<SVGIcon name="dashboard" size="lg" /> | ||
<SVGIcon name="dashboard" size="xl" /> | ||
<SVGIcon name="dashboard" size="xxl" /> | ||
</Flex> | ||
</Story> | ||
</Preview> | ||
|
||
### Icons colors | ||
|
||
<Preview> | ||
<Story name="colors"> | ||
<Flex justifyContent="space-evenly"> | ||
<SVGIcon name="dashboard" /> | ||
<SVGIcon name="dashboard" color="success"/> | ||
<SVGIcon name="dashboard" color="danger"/> | ||
<SVGIcon name="dashboard" color="warning"/> | ||
<SVGIcon name="dashboard" color="notification"/> | ||
</Flex> | ||
</Story> | ||
</Preview> | ||
|
||
### Menu Icons | ||
|
||
<Preview> | ||
<Story name="menu"> | ||
<Flex justifyContent="space-evenly"> | ||
<SVGIcon name="dashboard" size="lg" /> | ||
<SVGIcon name="application" size="lg" /> | ||
<SVGIcon name="cloudAccounts" size="lg" /> | ||
<SVGIcon name="resource" size="lg" /> | ||
<SVGIcon name="organizationalStructure" size="lg" /> | ||
<SVGIcon name="contactPersons" size="lg" /> | ||
<SVGIcon name="users" size="lg" /> | ||
<SVGIcon name="mappingRules" size="lg" /> | ||
<SVGIcon name="costSplittingRules" size="lg" /> | ||
<SVGIcon name="actionLog" size="lg" /> | ||
<SVGIcon name="businessUnitType" size="lg" /> | ||
</Flex> | ||
</Story> | ||
</Preview> | ||
|
||
### UI Icons | ||
|
||
<Preview> | ||
<Story name="ui"> | ||
<Flex justifyContent="space-evenly"> | ||
<SVGIcon name="danger" /> | ||
<SVGIcon name="success" /> | ||
<SVGIcon name="info" /> | ||
<SVGIcon name="help" /> | ||
<SVGIcon name="plus" /> | ||
<SVGIcon name="minus" /> | ||
</Flex> | ||
</Story> | ||
</Preview> | ||
|
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
Large diffs are not rendered by default.
Oops, something went wrong.