1
0
mirror of https://github.com/kremalicious/portfolio.git synced 2024-12-22 09:13:19 +01:00

use SVGR directly

This commit is contained in:
Matthias Kretschmann 2018-06-20 23:26:40 +02:00
parent 3f47580dcf
commit 88bbd1fb2f
Signed by: m
GPG Key ID: 606EEEF3C479A91F
8 changed files with 70 additions and 68 deletions

1
.gitignore vendored
View File

@ -11,3 +11,4 @@ yarn-debug.log*
yarn.lock
package-lock.json
plugins/gatsby-plugin-matomo
src/components/svg

View File

@ -58,14 +58,6 @@ module.exports = {
localScript: '/piwik.js'
}
},
{
resolve: 'gatsby-plugin-svgr',
options: {
icon: false,
viewBox: true
// see https://github.com/smooth-code/svgr for a list of all options
}
},
{
resolve: 'gatsby-plugin-favicon',
options: {

View File

@ -10,13 +10,14 @@
"lint:js": "eslint ./gatsby-*.{js,jsx} && eslint ./src/**/*.{js,jsx}",
"lint:css": "stylelint ./src/**/*.{css,scss}",
"lint": "npm run lint:js && npm run lint:css",
"build": "./node_modules/gatsby/dist/bin/gatsby.js build",
"start": "./node_modules/gatsby/dist/bin/gatsby.js develop",
"build": "npm run svg && ./node_modules/gatsby/dist/bin/gatsby.js build",
"start": "npm run svg && ./node_modules/gatsby/dist/bin/gatsby.js develop",
"format": "prettier --write 'src/**/*.{js,jsx}'",
"format:css": "prettier-stylelint --write --quiet 'src/**/*.{css,scss}'",
"test": "npm run lint",
"deploy": "./scripts/deploy.sh",
"new": "node ./scripts/new-project.js"
"new": "node ./scripts/new-project.js",
"svg": "./scripts/svg.sh"
},
"dependencies": {
"camel-case": "^3.0.0",
@ -31,7 +32,6 @@
"gatsby-plugin-sass": "next",
"gatsby-plugin-sharp": "next",
"gatsby-plugin-sitemap": "next",
"gatsby-plugin-svgr": "github:plag/gatsby-plugin-svgr#gatsby2-compatibility",
"gatsby-source-filesystem": "next",
"gatsby-transformer-json": "next",
"gatsby-transformer-sharp": "next",
@ -49,6 +49,7 @@
"vcf": "^2.0.1"
},
"devDependencies": {
"@svgr/cli": "^2.0.0",
"babel-eslint": "^8.2.3",
"eslint": "^5.0.0",
"eslint-config-prettier": "^2.9.0",

8
scripts/svg.sh Executable file
View File

@ -0,0 +1,8 @@
#!/usr/bin/env bash
set -e
SRC='./src/images'
OUT='./src/components/svg'
# Usage: svgr [-d out-dir] [src-dir]
./node_modules/@svgr/cli/bin/svgr --icon -d $OUT $SRC

View File

@ -1,6 +1,6 @@
import React from 'react'
import PropTypes from 'prop-types'
// import { ReactComponent as Logo } from '../../images/logo.svg'
import Logo from '../svg/Logo'
import styles from './LogoUnit.module.scss'
const LogoUnit = ({ meta, minimal }) => {
@ -10,7 +10,7 @@ const LogoUnit = ({ meta, minimal }) => {
return (
<div className={classes}>
{/* <Logo className={styles.logounit__logo} /> */}
<Logo className={styles.logounit__logo} />
<h1 className={styles.logounit__title}>{meta.title.toLowerCase()}</h1>
<p className={styles.logounit__description}>
<span>{'{ '}</span> {meta.tagline.toLowerCase()} <span>{' }'}</span>

View File

@ -2,31 +2,31 @@ import React, { PureComponent } from 'react'
import PropTypes from 'prop-types'
import { FadeIn } from '../atoms/Animations'
// import { ReactComponent as Email } from '../../images/email.svg'
// import { ReactComponent as Blog } from '../../images/blog.svg'
// import { ReactComponent as Twitter } from '../../images/twitter.svg'
// import { ReactComponent as GitHub } from '../../images/github.svg'
// import { ReactComponent as Dribbble } from '../../images/dribbble.svg'
import Email from '../svg/Email'
import Blog from '../svg/Blog'
import Twitter from '../svg/Twitter'
import GitHub from '../svg/Github'
import Dribbble from '../svg/Dribbble'
// import icons from '../atoms/Icons.module.scss'
import icons from '../atoms/Icons.module.scss'
import styles from './Networks.module.scss'
// const NetworkIcon = props => {
// switch (props.title) {
// case 'Email':
// return <Email {...props} />
// case 'Blog':
// return <Blog {...props} />
// case 'Twitter':
// return <Twitter {...props} />
// case 'GitHub':
// return <GitHub {...props} />
// case 'Dribbble':
// return <Dribbble {...props} />
// default:
// return null
// }
// }
const NetworkIcon = props => {
switch (props.title) {
case 'Email':
return <Email {...props} />
case 'Blog':
return <Blog {...props} />
case 'Twitter':
return <Twitter {...props} />
case 'GitHub':
return <GitHub {...props} />
case 'Dribbble':
return <Dribbble {...props} />
default:
return null
}
}
class Network extends PureComponent {
constructor(props) {
@ -64,7 +64,7 @@ class Network extends PureComponent {
href={this.props.meta.social[key]}
key={i}
>
{/* <NetworkIcon title={key} className={icons.icon} /> */}
<NetworkIcon title={key} className={icons.icon} />
<span className={styles.title}>{key}</span>
</a>
))}

View File

@ -1,34 +1,34 @@
import React from 'react'
import PropTypes from 'prop-types'
// import { ReactComponent as Link } from '../../images/link.svg'
// import { ReactComponent as Download } from '../../images/download.svg'
// import { ReactComponent as Info } from '../../images/info.svg'
// import { ReactComponent as Styleguide } from '../../images/styleguide.svg'
// import { ReactComponent as GitHub } from '../../images/github.svg'
// import { ReactComponent as Dribbble } from '../../images/dribbble.svg'
import Link from '../svg/Link'
import Download from '../svg/Download'
import Info from '../svg/Info'
import Styleguide from '../svg/Styleguide'
import GitHub from '../svg/Github'
import Dribbble from '../svg/Dribbble'
// import icons from '../atoms/Icons.module.scss'
import icons from '../atoms/Icons.module.scss'
import styles from './ProjectLinks.module.scss'
// const LinkIcon = props => {
// switch (props.title) {
// case 'Link':
// return <Link {...props} />
// case 'GitHub':
// return <GitHub {...props} />
// case 'Dribbble':
// return <Dribbble {...props} />
// case 'Info':
// return <Info {...props} />
// case 'Download':
// return <Download {...props} />
// case 'Styleguide':
// return <Styleguide {...props} />
// default:
// return null
// }
// }
const LinkIcon = props => {
switch (props.title) {
case 'Link':
return <Link {...props} />
case 'GitHub':
return <GitHub {...props} />
case 'Dribbble':
return <Dribbble {...props} />
case 'Info':
return <Info {...props} />
case 'Download':
return <Download {...props} />
case 'Styleguide':
return <Styleguide {...props} />
default:
return null
}
}
const ProjectLinks = ({ links }) => (
<div className={styles.projectLinks}>
@ -43,7 +43,7 @@ const ProjectLinks = ({ links }) => (
return (
<li key={title}>
<a href={url}>
{/* <LinkIcon title={title} className={icons.icon} /> */}
<LinkIcon title={title} className={icons.icon} />
{title}
</a>
</li>

View File

@ -2,20 +2,20 @@ import React, { PureComponent, Fragment } from 'react'
import PropTypes from 'prop-types'
import Helmet from 'react-helmet'
import { FadeIn } from '../atoms/Animations'
// import { ReactComponent as Day } from '../../images/day.svg'
// import { ReactComponent as Night } from '../../images/night.svg'
import Day from '../svg/Day'
import Night from '../svg/Night'
import styles from './ThemeSwitch.module.scss'
const ThemeToggle = () => {
const ThemeToggle = props => {
return (
<span
id="toggle"
className={styles.checkboxContainer}
aria-live="assertive"
>
{/* <Day className={props.dark ? null : 'active'} /> */}
<Day className={props.dark ? null : 'active'} />
<span className={styles.checkboxFake} />
{/* <Night className={props.dark ? 'active' : null} /> */}
<Night className={props.dark ? 'active' : null} />
</span>
)
}