Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refact some files #114

Merged
merged 13 commits into from
Sep 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"presets": [
"@babel/react",
"@babel/react",
],
"plugins": [
"@babel/plugin-proposal-class-properties"
"@babel/plugin-proposal-class-properties",
"react-hot-loader/babel"
]
}
1 change: 0 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
node_modules/
public/
webpack.config.js
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"husky": "^1.3.1",
"react": "^16.7.0",
"react-dom": "^16.7.0",
"react-hot-loader": "^4.12.10",
"react-markdown": "^4.0.6",
"react-scripts": "2.1.3",
"webpack-merge": "^4.2.1"
Expand All @@ -23,7 +24,7 @@
}
},
"scripts": {
"start": "webpack-dev-server --config ./webpack/webpack.dev.js --progress --colors --inline --hot --host 0.0.0.0",
"start": "webpack-dev-server --config ./webpack/webpack.dev.js --progress --colors",
"build": "webpack --config ./webpack/webpack.prod.js",
"lint": "eslint ."
},
Expand Down
2 changes: 1 addition & 1 deletion src/components/app/App.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.main {
height: 100%;
display: grid;
grid-template-rows: auto max-content;
grid-template-rows: auto 14%;
}

10 changes: 6 additions & 4 deletions src/components/app/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ import Footer from "./Footer/Footer"
import './App.css';

const App = () => (
<div className={"main"}>
<Route path="/:term?" component={GlossaryPage}/>
<Footer className={"main__footer"}/>
</div>
<div className="main">
<main>
<Route path="/:term?" component={GlossaryPage}/>
</main>
<Footer/>
</div>
);

export default App;
7 changes: 2 additions & 5 deletions src/components/app/Footer/Footer.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@
display: grid;
grid-template-areas:
"contribute about";
grid-template-columns: max-content max-content;
grid-template-rows: 100%;
grid-gap: 5em;
align-items: center;
justify-content: center;
padding: 24px;
place-content: center;
place-items: center;
}

@media screen and (max-width: 475px){
Expand All @@ -19,5 +17,4 @@
grid-template-rows: max-content max-content;
grid-gap: 0.5em;
}

}
21 changes: 11 additions & 10 deletions src/components/app/Footer/Footer.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
import React from 'react';
import "./Footer.css"

import { IconWithText } from "../../common/index"
import { IconWithText } from "../../common"
import "./Footer.css"

const contributionLink = "https://github.com/OpenDevUFCG/glossario-ufcg/blob/master/CONTRIBUTING.md";
const aboutLink = "https://opendevufcg.org/";
const linkClass = "pointer-hover no-decoration lighter-hover";

const Footer = () => (
<div className={'glossary-footer'}>
<a className={"pointer-hover no-decoration lighter-hover"} href={contributionLink}>
<IconWithText icon={"inbox"} text={"Como contribuir?"}/>
</a>
<a className={"pointer-hover no-decoration lighter-hover"} href={aboutLink}>
<IconWithText icon={"people"} text={"Quem somos?"}/>
</a>
</div>
<footer className='glossary-footer'>
<a className={linkClass} href={contributionLink}>
<IconWithText icon='inbox' text='Como contribuir?'/>
</a>
<a className={linkClass} href={aboutLink}>
<IconWithText icon='people' text='Quem somos?'/>
</a>
</footer>
);


Expand Down
6 changes: 3 additions & 3 deletions src/components/common/Icon/Icon.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from 'react';

const Icon = (props) => (
<i className="material-icons" style={{color: props.iconColor, fontSize: props.size}}>
{props.icon}
const Icon = ({ icon, iconColor, size }) => (
<i className="material-icons" style={{color: iconColor, fontSize: size}}>
{icon}
</i>
);

Expand Down
13 changes: 13 additions & 0 deletions src/components/common/Icon/IconButton/IconButton.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React from 'react';
import Icon from "../Icon";

const IconButton = ({ icon, iconColor, action}) => (
<button
className='odu-icon-button align-self-center'
onClick={action}
>
<Icon icon={icon} iconColor={iconColor}/>
</button>
);

export default IconButton;
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@
align-items: center;
justify-content: center;
font-weight: bold;
margin: 0;
font-size: 1.2em;
}
13 changes: 13 additions & 0 deletions src/components/common/Icon/IconWithText/IconWithText.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React from 'react';
import "./IconWithText.css"

import Icon from "../Icon"

const IconWithText = ({ icon, text }) => (
<figure className='icon-with-text light-accent'>
<Icon icon={icon} size='30px'/>
<figcaption>{text}</figcaption>
</figure>
);

export default IconWithText;
9 changes: 9 additions & 0 deletions src/components/common/Icon/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import Icon from './Icon'
import IconButton from './IconButton/IconButton'
import IconWithText from './IconWithText/IconWithText'

export {
Icon,
IconButton,
IconWithText
}
10 changes: 0 additions & 10 deletions src/components/common/IconButton/IconButton.js

This file was deleted.

13 changes: 0 additions & 13 deletions src/components/common/IconWithText/IconWithText.js

This file was deleted.

29 changes: 16 additions & 13 deletions src/components/common/Search/Search.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,34 @@
import * as React from 'react';
import "./Search.css";
import { AutoComplete, Select } from 'antd';
import Icon from "../Icon/Icon";
import { Icon } from "../Icon";

const renderOption = (item) => (
<Select.Option key={item}>
{item}
</Select.Option>
);

const CustomSearchButton = (props) => (
<button className={"search__button-container pointer-hover lighter-hover"} onClick={props.handleClick}>
<Icon className={"search__button"} icon={"search"} iconColor={"#FFFFFF"}/>
</button>
const CustomSearchButton = ({ handleClick }) => (
<button
className='search__button-container pointer-hover lighter-hover'
onClick={handleClick}
>
<Icon className='search__button' icon='search' iconColor='#FFFFFF"'/>
</button>
);

const Search = (props) => (
<div className={"search"}>
const Search = ({ items, handleSelect }) => (
<aside className='search'>
<AutoComplete
dataSource={props.items.map(renderOption)}
optionLabelProp="meaning"
placeholder="Pesquise..."
onSelect={e => props.handleSelect(e)}
filterOption={(inputValue, option) => option.props.children.toUpperCase().indexOf(inputValue.toUpperCase()) !== -1}
dataSource={items.map(renderOption)}
optionLabelProp='meaning'
placeholder='Pesquise...'
onSelect={e => handleSelect(e)}
filterOption={(inputValue, option) => option.props.children.toUpperCase().indexOf(inputValue.toUpperCase()) !== -1}
/>
<CustomSearchButton/>
</div>
</aside>
);

export default Search;
14 changes: 9 additions & 5 deletions src/components/common/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import Icon from './Icon/Icon';
import IconButton from './IconButton/IconButton';
import IconWithText from './IconWithText/IconWithText';
import { Icon, IconButton, IconWithText } from './Icon';
import Search from './Search/Search';
import TermCard from './TermCard/TermCard';
import Markdown from './Markdown/Markdown';


export { Icon, IconButton, IconWithText, Search, TermCard, Markdown };
export {
Icon,
IconButton,
IconWithText,
Search,
TermCard,
Markdown
};
14 changes: 6 additions & 8 deletions src/components/glossary/GlossaryPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,13 @@ class GlossaryPage extends Component {
<Search className={"glossary__search"}
items={Object.keys(terms).sort()}
handleSelect={this.handleAcronymChange}/>
{this.isSearchEmpty() ?
<DayPhrase entry={randomEntry}/> :
""
}
{this.isSearchEmpty() && (
<DayPhrase entry={randomEntry}/>
)}
</div>
{!this.isSearchEmpty() ?
<SearchResults term={this.getTerm()}/> :
""
}
{!this.isSearchEmpty() && (
thayannevls marked this conversation as resolved.
Show resolved Hide resolved
<SearchResults term={this.getTerm()}/>
)}
</div>
);
}
Expand Down
1 change: 1 addition & 0 deletions src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ html, body {
font-family: 'Krub', sans-serif;
font-size: 16px;
margin: 0;
padding: 0;
}

@font-face {
Expand Down
2 changes: 1 addition & 1 deletion src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<title>Glossario UFCG</title>
<meta name="viewport" charset="UTF-8" content="width=device-width, initial-scale=1">
<meta charset="utf-8" />
<link href="assets/images/favicon.ico" rel="icon">
<link href="../assets/images/favicon.ico" type="image/png" rel="shortcut icon"/>
<link href="https://fonts.googleapis.com/css?family=Krub:400,500" rel="stylesheet">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
</head>
Expand Down
1 change: 0 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import App from './components/app/App'
import { HashRouter } from 'react-router-dom'

import './index.css';
import './styles/material/colors.css';
import './styles/odu/odu.css';
import './styles/odu/colors.css';
import './styles/utils.css';
Expand Down
Empty file removed src/styles/material/colors.css
Empty file.
7 changes: 3 additions & 4 deletions webpack/webpack.common.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
const webpack = require('webpack');
const path = require('path');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const HtmlWebPackPlugin = require("html-webpack-plugin");

const parentDir = path.join(__dirname, '../');

const config = {
entry: [`${parentDir}/src/index.js`],
entry: [`${parentDir}src/index.js`],
output: {
path: `${parentDir}public/`,
filename: 'bundle.[hash].js',
Expand All @@ -16,7 +15,7 @@ const config = {
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: 'babel-loader',
use: 'babel-loader'
},
{
test: /\.(jpg|jpeg|gif|png|svg)$/,
Expand Down Expand Up @@ -51,7 +50,7 @@ const config = {
filename: 'style.css',
}),
new HtmlWebPackPlugin({
template: `${parentDir}/src/index.html`,
template: `${parentDir}src/index.html`,
filename: "index.html"
})
]
Expand Down
10 changes: 7 additions & 3 deletions webpack/webpack.dev.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
const webpack = require('webpack');
const merge = require('webpack-merge');
const path = require('path');
const common = require('./webpack.common');

const parentDir = path.join(__dirname, '../');

module.exports = merge(common, {
entry: ['react-dev-utils/webpackHotDevClient'],
entry: ['react-hot-loader/patch'],
devServer: {
port: 8000,
contentBase: `${parentDir}public`,
contentBase: [`${parentDir}public`],
historyApiFallback: true,
watchContentBase: true,
hot: true,
inline: true,
host: '0.0.0.0',
},
mode: 'development',
});

1 change: 0 additions & 1 deletion webpack/webpack.prod.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
const webpack = require('webpack');
const merge = require('webpack-merge');
const common = require('./webpack.common');

Expand Down
Loading