Skip to content

Commit

Permalink
cards style
Browse files Browse the repository at this point in the history
  • Loading branch information
ganevdev committed Sep 20, 2018
1 parent c157a8a commit 6972ecf
Show file tree
Hide file tree
Showing 17 changed files with 213 additions and 130 deletions.
1 change: 1 addition & 0 deletions .flowconfig
@@ -1,4 +1,5 @@
[ignore]
./node_modules/styled-components/.*

[include]

Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Expand Up @@ -51,4 +51,7 @@ node_modules/

.serverless/
yarn.lock
package-lock.json
package-lock.json

# Flow
flow-typed
3 changes: 2 additions & 1 deletion .prettierrc
@@ -1,5 +1,6 @@
{
"trailingComma": "es5",
"arrowParens": "always",
"trailingComma": "all",
"semi": false,
"singleQuote": true,
"tabWidth": 2
Expand Down
6 changes: 0 additions & 6 deletions gatsby-config.js
Expand Up @@ -56,12 +56,6 @@ module.exports = {
},
`gatsby-plugin-offline`,
`gatsby-plugin-react-helmet`,
{
resolve: 'gatsby-plugin-typography',
options: {
pathToConfigModule: 'src/utils/typography',
},
},
`gatsby-plugin-styled-components`,
`gatsby-plugin-flow`,
],
Expand Down
13 changes: 7 additions & 6 deletions package.json
Expand Up @@ -18,7 +18,6 @@
"gatsby-plugin-offline": "^2.0.0",
"gatsby-plugin-react-helmet": "^3.0.0",
"gatsby-plugin-sharp": "^2.0.0",
"gatsby-plugin-typography": "^2.0.0",
"gatsby-remark-copy-linked-files": "^2.0.0",
"gatsby-remark-images": "^2.0.0",
"gatsby-image": "^2.0.0",
Expand All @@ -33,20 +32,22 @@
"react": "^16.5.1",
"react-dom": "^16.5.1",
"react-helmet": "^5.2.0",
"react-typography": "^0.16.13",
"typography": "^0.16.17",
"typography-breakpoint-constants": "^0.15.10",
"typography-theme-wordpress-2016": "^0.15.10",
"babel-plugin-styled-components": "^1.5.1",
"styled-components": "^3.3.2"
},
"devDependencies": {
"eslint": "^5.0.0",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-jsx-a11y": "^6.1.1",
"eslint-plugin-react": "^7.7.0",
"eslint-config-prettier": "^3.0.1",
"eslint-plugin-flowtype": "^2.50.1",
"eslint-config-airbnb": "^17.1.0",
"gh-pages": "^1.1.0",
"prettier": "^1.12.0",
"@babel/core": "^7.0.1",
"flow-bin": "^0.81.0"
"flow-bin": "^0.81.0",
"flow-typed": "^2.5.1"
},
"scripts": {
"dev": "gatsby develop",
Expand Down
8 changes: 4 additions & 4 deletions site-config.js
Expand Up @@ -4,15 +4,15 @@ module.exports = {
author: 'Kyle Mathews',
description: 'A starter blog demonstrating what Gatsby can do.',
siteUrl: 'https://gatsbyjs.github.io/gatsby-starter-blog/',
footerText: '© 2018 copyrate',

// Site Style:
font: 'Merriweather',
fontHeadings: 'Zilla Slab',
mainColor: '#7D4CDB', // #7D4CDB
backgroundColor: '#F6F6F6', // #F6F6F6
fontHeadings: 'Merriweather',
brandColor: '#7D4CDB', // #7D4CDB
backgroundColor: '#fff', // #fff

// TODO:
// backgroundColor: `#fff`,
// pathPrefix: null,
// logo: path.resolve(__dirname, 'src/images/icon.png'),
// social: {
Expand Down
70 changes: 56 additions & 14 deletions src/components/CardPost.js
@@ -1,17 +1,59 @@
import React from 'react'
import React, { Component } from 'react'
import { Link, graphql } from 'gatsby'
import { Box } from 'grommet'
import { Box, Image, Text, Heading } from 'grommet'

export default props => {
return (
<Box border={{ color: 'brand', size: 'medium' }} pad="small" round="small">
<h3>
<Link style={{ boxShadow: 'none' }} to={props.link}>
{props.title}
</Link>
</h3>
<small>{props.date}</small>
<p dangerouslySetInnerHTML={props.htmlExcerpt} />
</Box>
)
import styled from 'styled-components'

// Target another styled component on hover
// https://www.styled-components.com/docs/advanced#referring-to-other-components
// Psuedoelements, psuedoselectors, and nesting
// https://www.styled-components.com/docs/basics#psuedoelements-psuedoselectors-and-nesting

// https://www.gatsbyjs.org/docs/gatsby-link/
// https://reactjs.org/docs/events.html#mouse-events

export default class extends Component {
// const CardLink = styled.Link`
// color: blue;

// :hover {
// color: red;
// }
// `

render() {
return (
<Link
to={this.props.link}
style={{
boxShadow: 'none',
textDecoration: 'none',
textColor: 'none',
}}
>
<Box
round="small"
margin="small"
elevation="small"
background="light-2"
>
<Box
basis="medium"
fill="true"
round="small"
background={{ image: 'url(' + this.props.cover + ')' }}
/>
<Box pad="medium">
<Heading margin="xsmall" level="3">
{this.props.title}
</Heading>
<Text dangerouslySetInnerHTML={this.props.htmlExcerpt} />
<Text margin={{ top: 'small' }} size="small">
{this.props.date}
</Text>
</Box>
</Box>
</Link>
)
}
}
14 changes: 10 additions & 4 deletions src/components/CardProfile.js
@@ -1,19 +1,25 @@
import React from 'react'
import { Box } from 'grommet'
import { Box, Text } from 'grommet'

import profilePic from './profile-pic.jpg'

export default () => {
return (
<Box border={{ color: 'brand', size: 'medium' }} pad="small" round="small">
<Box
round="small"
pad="small"
margin="small"
background="light-2"
// border={{ size: 'small', color: 'brand' }}
>
<img src={profilePic} alt={`Kyle Mathews`} />
<p>
<Text size="small">
Written by <strong>Kyle Mathews</strong> who lives and works in San
Francisco building useful things.{' '}
<a href="https://twitter.com/kylemathews">
You should follow him on Twitter
</a>
</p>
</Text>
</Box>
)
}
11 changes: 11 additions & 0 deletions src/components/Footer.js
@@ -0,0 +1,11 @@
import React from 'react'
import { Box, Text } from 'grommet'
import siteConfig from '../../site-config'

export default () => {
return (
<Box background="light-2" pad="large">
<Text>{siteConfig.footerText}</Text>
</Box>
)
}
46 changes: 33 additions & 13 deletions src/components/Layout.js
@@ -1,30 +1,50 @@
import React, { Component } from 'react'
import { Grommet, Box, Grid } from 'grommet'

import { injectGlobal } from 'styled-components'

import { siteTheme } from '../site-theme'
import siteConfig from '../../site-config'

import Navbar from './Navbar'
import CardProfile from './CardProfile'
import Footer from './Footer'

injectGlobal`
img {
border-radius: 12px;
}
body {
margin: 0
}
a:hover {
opacity: 0.8;
}
`

export default class Template extends Component {
render() {
return (
<Grommet theme={siteTheme}>
<Box
background={siteConfig.backgroundColor}
style={{ minHeight: '100vh' }}
responsive
>
<Navbar />
<Box direction="row-responsive" responsive>
<Box>
<CardProfile />
<div>
<Grommet theme={siteTheme}>
<Box
background={siteConfig.backgroundColor}
style={{ minHeight: '100vh' }}
responsive
margin="small"
align="center"
>
<Navbar />
<Box direction="row-responsive">
<Box width="medium">
<CardProfile />
</Box>
<Box width="large">{this.props.children}</Box>
</Box>
<Box>{this.props.children}</Box>
</Box>
</Box>
</Grommet>
<Footer />
</Grommet>
</div>
)
}
}
24 changes: 14 additions & 10 deletions src/components/Navbar.js
@@ -1,6 +1,6 @@
import React, { Component } from 'react'

import { Grommet, Heading, Anchor, Text } from 'grommet'
import { Grommet, Heading, Anchor, Text, Box } from 'grommet'

import { siteTheme } from '../site-theme'

Expand All @@ -9,20 +9,24 @@ import styled from 'styled-components'
export class Navbar extends Component {
render() {
const rootPath = `${__PATH_PREFIX__}/`
const SiteName = styled(Text)`
const SiteName = styled(Heading)`
color: ${siteTheme.global.colors.brand};
font-family: ${siteTheme.global.heading.font.family};
font-size: 30px !important;
line-height: 56px;
max-width: 1200px;
font-weight: 600;
margin-top: 3.5rem;
`

return (
<Anchor href="/">
<SiteName
tag={location.pathname === rootPath ? 'h1' : 'h5'}
size="xxlarge"
>
Gatsby Starter Blog
</SiteName>
</Anchor>
<Box margin="small">
<Anchor href="/">
<SiteName level={location.pathname === rootPath ? '1' : '4'}>
Gatsby Starter Blog
</SiteName>
</Anchor>
</Box>
)
}
}
Expand Down
22 changes: 22 additions & 0 deletions src/pages/blog/test-test/index.md
@@ -0,0 +1,22 @@
---
title: Hello World TEST
date: '2018-03-01T22:12:03.284Z'
cover: './salty_egg.jpg'
---

This is my first post on my new fake blog! How exciting!

I'm sure I'll write a lot more interesting things in the future.

Oh, and here's a great quote from this Wikipedia on
[salted duck eggs](http://en.wikipedia.org/wiki/Salted_duck_egg).

> A salted duck egg is a Chinese preserved food product made by soaking duck
> eggs in brine, or packing each egg in damp, salted charcoal. In Asian
> supermarkets, these eggs are sometimes sold covered in a thick layer of salted
> charcoal paste. The eggs may also be sold with the salted paste removed,
> wrapped in plastic, and vacuum packed. From the salt curing process, the
> salted duck eggs have a briny aroma, a gelatin-like egg white and a
> firm-textured, round yolk that is bright orange-red in color.
![Chinese Salty Egg](./salty_egg.jpg)
Binary file added src/pages/blog/test-test/salty_egg.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 11 additions & 5 deletions src/pages/index.js
@@ -1,19 +1,17 @@
import React from 'react'
import React, { Component } from 'react'
import { Link, graphql } from 'gatsby'
import get from 'lodash/get'
import Helmet from 'react-helmet'

import Layout from '../components/Layout'
import CardPost from '../components/CardPost'

import { rhythm } from '../utils/typography'

class BlogIndex extends React.Component {
class BlogIndex extends Component {
render() {
const siteTitle = get(this, 'props.data.site.siteMetadata.title')
const siteDescription = get(
this,
'props.data.site.siteMetadata.description'
'props.data.site.siteMetadata.description',
)
const posts = get(this, 'props.data.allMarkdownRemark.edges')

Expand All @@ -30,6 +28,7 @@ class BlogIndex extends React.Component {
<div key={node.fields.slug}>
<CardPost
link={node.fields.slug}
cover={node.frontmatter.cover.childImageSharp.fluid.src}
title={title}
date={node.frontmatter.date}
htmlExcerpt={{ __html: node.excerpt }}
Expand Down Expand Up @@ -62,6 +61,13 @@ export const pageQuery = graphql`
frontmatter {
date(formatString: "DD MMMM, YYYY")
title
cover {
childImageSharp {
fluid {
src
}
}
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/site-theme.js
Expand Up @@ -13,7 +13,7 @@ export const siteTheme = {
},
},
colors: {
brand: siteConfig.mainColor,
brand: siteConfig.brandColor,
},
},
}

0 comments on commit 6972ecf

Please sign in to comment.