Skip to content

Instantly share code, notes, and snippets.

View chetanraj's full-sized avatar
🎯
Focusing

Chetan chetanraj

🎯
Focusing
View GitHub Profile
import styled from 'styled-components';
import { border, color, compose, flexbox, layout, position, shadow, space, typography } from 'styled-system';
export const Div = styled('div')(
compose(border, space, layout, typography, color, position, shadow, flexbox)
);
export const Flex = styled(Div)`
display: flex;
export const theme = {
breakpoints: [32, 48, 64],
space: [0, 4, 8, 16, 24, 32, 48, 64, 128, 256, 512],
fontSizes: [12, 14, 16, 18, 20, 24, 36, 48, 80, 96],
fontWeights: [100, 200, 300, 400, 500, 600, 700, 800, 900],
lineHeights: {
normal: 1,
title: 1.25,
paragraph: 1.5
},
export const pageQuery = graphql`
query BlogPostBySlug($slug: String!) {
site {
siteMetadata {
title
}
}
markdownRemark(fields: { slug: { eq: $slug } }) {
id
excerpt(pruneLength: 160)
import RehypeReact from "rehype-react"
const renderAst = new RehypeReact({
createElement: React.createElement,
components: {
h1: Title,
p: Paragraph,
},
}).Compiler;
import styled from "styled-components";
export const Title = styled.h1`
font-size: 3em;
text-align: center;
color: yellowgreen;
`;
export const Paragraph = styled.p`
font-size: 1em;
{
resolve: `gatsby-transformer-remark`,
options: {
plugins: [
{
resolve: `gatsby-remark-classes`,
options: {
classMap: {
"heading[depth=1]": "text-2xl",
"heading[depth=2]": "text-xl",
import React from 'react';
import styled from 'styled-components';
const StyledInput = styled.input`
color: ${props => props.disabled ? `${props.theme.colors.gray}` : `${props.theme.colors.darkgray}`};
font-size: ${props => `${props.theme.fontSizes[2]}px`};
border: 1px solid;
border-color: ${props => props.theme.colors[props.borderColor] || props.theme.colors.lightgray};
background: ${props => props.theme.colors[props.bg] || props.theme.colors.white};
border-radius: ${props => `${props.theme.radii[2]}`};
export const theme = {
breakpoints: [32, 48, 64],
space: [0, 4, 8, 16, 24, 32, 48, 64, 128, 256, 512],
fontSizes: [12, 14, 16, 18, 20, 24, 36, 48, 80, 96],
fontWeights: [100, 200, 300, 400, 500, 600, 700, 800, 900],
lineHeights: {
normal: 1,
title: 1.25,
paragraph: 1.5
},
@chetanraj
chetanraj / useName.js
Created October 8, 2020 10:05
../logics/useName.js
import React, { useState } from 'react';
const useName = () => {
const [name, setValue] = useState('');
const setName = name => {
setValue(name);
};
return { name, setName };
@chetanraj
chetanraj / Create.js
Created October 8, 2020 10:04
../pages/Create/index.js
import React from 'react';
import { useName } from '../logics/useName';
const Create = () => {
const { name, setName } = useName();
const onChange = e => {
setName(e.target.value);
};