Skip to content
This repository has been archived by the owner on Feb 9, 2022. It is now read-only.

Commit

Permalink
use svgr to generate icon components (#82)
Browse files Browse the repository at this point in the history
  • Loading branch information
prydonius authored Feb 16, 2018
1 parent fb05777 commit 34dbea7
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 3 deletions.
7 changes: 7 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM node:8.9 AS build
WORKDIR /app
COPY . /app
RUN yarn run build

FROM bitnami/nginx
COPY --from=build /app/build /app
2 changes: 1 addition & 1 deletion src/components/Footer/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from "react";
import logo from "../../logo.svg";

// Icons
import Heart from "!react-svg-loader!open-iconic/svg/heart.svg";
import Heart from "../../icons/Heart";

class Footer extends React.Component {
public render() {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { IRouterPathname } from "../../shared/types";
import HeaderLink, { IHeaderLinkProps } from "./HeaderLink";

// Icons
import Cog from "!react-svg-loader!open-iconic/svg/cog.svg";
import Cog from "../../icons/Cog";

import "./Header.css";

Expand Down
12 changes: 12 additions & 0 deletions src/icons/Cog.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import * as React from "react";

const Cog = (props: any) => (
<svg viewBox="0 0 8 8" width="1em" height="1em" {...props}>
<path
fill="currentColor"
d="M3.5 0L3 1.19c-.1.03-.19.08-.28.13L1.53.82l-.72.72.5 1.19c-.05.1-.09.18-.13.28l-1.19.5v1l1.19.5c.04.1.08.18.13.28l-.5 1.19.72.72 1.19-.5c.09.04.18.09.28.13l.5 1.19h1L5 6.83c.09-.04.19-.08.28-.13l1.19.5.72-.72-.5-1.19c.04-.09.09-.19.13-.28l1.19-.5v-1l-1.19-.5c-.03-.09-.08-.19-.13-.28l.5-1.19-.72-.72-1.19.5c-.09-.04-.19-.09-.28-.13L4.5 0h-1zM4 2.5c.83 0 1.5.67 1.5 1.5S4.83 5.5 4 5.5 2.5 4.83 2.5 4 3.17 2.5 4 2.5z"
/>
</svg>
);

export default Cog;
12 changes: 12 additions & 0 deletions src/icons/Heart.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import * as React from "react";

const Heart = (props: any) => (
<svg viewBox="0 0 8 8" width="1em" height="1em" {...props}>
<path
fill="currentColor"
d="M2 1c-.55 0-1.04.23-1.41.59C.23 1.95 0 2.44 0 3c0 .55.23 1.04.59 1.41L4 7.82l3.41-3.41C7.77 4.05 8 3.56 8 3c0-.55-.23-1.04-.59-1.41C7.05 1.23 6.56 1 6 1c-.55 0-1.04.23-1.41.59C4.23 1.95 4 2.44 4 3c0-.55-.23-1.04-.59-1.41C3.05 1.23 2.56 1 2 1z"
/>
</svg>
);

export default Heart;
15 changes: 15 additions & 0 deletions src/icons/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
These icons are generated using svgr using SVGs from the open-iconic project.

In order to add a new icon, install svgr:

```
yarn global install svgr
```

Find the icon SVG file you want to use and edit it to ensure it sets `fill="currentColor"` in the path element.

Then run (replacing with the icon you want to use):

```
svgr --no-semi --icon node_modules/open-iconic/svg/cog.svg > src/icons/Cog.tsx
```
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"baseUrl": "src",
"outDir": "build/dist",
"module": "esnext",
"target": "es6",
"target": "es5",
"lib": ["dom", "es6"],
"sourceMap": true,
"allowJs": true,
"jsx": "react",
Expand Down

0 comments on commit 34dbea7

Please sign in to comment.