Skip to content

Commit

Permalink
add raw css classes
Browse files Browse the repository at this point in the history
  • Loading branch information
tuan2311 committed Aug 6, 2020
1 parent 3c66189 commit e492337
Show file tree
Hide file tree
Showing 11 changed files with 90 additions and 27 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ module.exports = {
rules: {
'react/prop-types': 'off', // Disable prop-types as we use TypeScript for type checking
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
},
overrides: [
Expand Down
9 changes: 0 additions & 9 deletions babel-plugin-macros.config.js

This file was deleted.

12 changes: 1 addition & 11 deletions gatsby-browser.js
Original file line number Diff line number Diff line change
@@ -1,11 +1 @@
/**
* Implement Gatsby's Browser APIs in this file.
*
* See: https://www.gatsbyjs.org/docs/browser-apis/
*/

// You can delete this file if you're not using it

import 'tailwindcss/dist/base.min.css';
import 'tailwindcss/dist/components.css';
import 'tailwindcss/dist/utilities.css';
import './src/index.css';
1 change: 1 addition & 0 deletions gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module.exports = {
author: `@gatsbyjs`,
},
plugins: [
`gatsby-plugin-postcss`,
`gatsby-plugin-emotion`,
`gatsby-plugin-react-helmet`,
{
Expand Down
10 changes: 10 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@
"@emotion/styled": "^10.0.27",
"@typescript-eslint/eslint-plugin": "^3.8.0",
"@typescript-eslint/parser": "^3.8.0",
"autoprefixer": "^9.8.6",
"eslint": "^7.6.0",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-prettier": "^3.1.4",
"eslint-plugin-react": "^7.20.5",
"gatsby-plugin-emotion": "^4.3.10",
"gatsby-plugin-postcss": "^2.3.11",
"husky": "^4.2.5",
"lint-staged": "^10.2.11",
"prettier": "2.0.5",
Expand Down
3 changes: 3 additions & 0 deletions postcss.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = () => ({
plugins: [require('tailwindcss'), require('autoprefixer')],
});
20 changes: 14 additions & 6 deletions src/components/home/Headline.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
import React from 'react';
import tw, { styled } from 'twin.macro';
import { Button } from '~/components/ui/controls/Button';

const HeadlineContainer = styled.div`
${tw`flex justify-between`}
const Root = styled.header`
${tw`bg-gray-200 py-5`}
`;

const Container = styled.div`
${tw`container flex justify-between items-center`}
`;

export default function Headline() {
return (
<HeadlineContainer>
<span>Here</span>
<div>Another one</div>
</HeadlineContainer>
<Root>
<Container>
<span>Here</span>
<Button>CONTACT ME</Button>
</Container>
</Root>
);
}
38 changes: 38 additions & 0 deletions src/components/ui/controls/Button.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import React from 'react';
import 'twin.macro';

type Props = {
size?: 'sm' | 'lg';
bgColor?: string;
rounded?: boolean;
textColor?: string;
children: any;
};
export const Button: React.FC<Props> = ({
size = 'sm',
bgColor = 'cta',
textColor = 'white',
children,
rounded = true,
}) => {
const sizeClass =
{
sm: 'text-xs',
lg: 'text-xl',
}[size] || '';

let bgClass = '';
if (bgColor) {
bgClass = `bg-${bgColor}`;
}

return (
<button
className={`${bgClass} text-${textColor} ${sizeClass} font-semibold py-2 px-4 ${
rounded ? 'rounded' : ''
}`}
>
{children}
</button>
);
};
3 changes: 3 additions & 0 deletions src/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@tailwind base;
@tailwind components;
@tailwind utilities;
18 changes: 17 additions & 1 deletion tailwind.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,23 @@
module.exports = {
purge: ['./src/**/*.js', './src/**/*.jsx', './src/**/*.ts', './src/**/*.tsx'],
theme: {
extend: {},
extend: {
colors: {
secondary: '#d1e0f4',
primary: '#0288d1',
cta: '#d10220',
info: '#2ecbf6',
warning: '#e4ca52',
success: '#49d96a',
danger: '#e75160',
},
},
container: {
center: true,
},
},
corePlugins: {
container: true,
},
variants: {},
plugins: [],
Expand Down

0 comments on commit e492337

Please sign in to comment.