Skip to content

Commit

Permalink
Please don't hate me for the quality of my code :(
Browse files Browse the repository at this point in the history
  • Loading branch information
wfdd committed May 27, 2016
0 parents commit 114b879
Show file tree
Hide file tree
Showing 25 changed files with 1,366 additions and 0 deletions.
1 change: 1 addition & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"presets": ["es2015", "react"]}
27 changes: 27 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[*.{es6,js}]
indent_size = 2
indent_style = space

[*.html]
indent_size = 2
indent_style = space

[*.py]
indent_size = 4
indent_style = space

[*.s?css]
indent_size = 2
indent_style = space

[*.{yaml,yml}]
indent_size = 2
indent_style = space
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/dist
/dump
/node_modules
/vendor
Empty file added .travis.yml
Empty file.
661 changes: 661 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
An experimental GitHub Pages frontend for the `openpatata`
written question data.

## License

AGPL v3.
1 change: 1 addition & 0 deletions assets/dropdown-arrow.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.
1 change: 1 addition & 0 deletions assets/gear.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions assets/gear.svg.attribution
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
https://thenounproject.com/term/gear/33317/
37 changes: 37 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"devDependencies": {
"autoprefixer": "^6.3.3",
"babel-core": "^6.7.2",
"babel-eslint": "^6.0.4",
"babel-loader": "^6.2.4",
"babel-preset-es2015": "^6.6.0",
"babel-preset-react": "^6.5.0",
"css-loader": "^0.23.1",
"eslint": "^2.4.0",
"eslint-plugin-babel": "^3.1.0",
"gh-pages": "^0.11.0",
"html-webpack-plugin": "^2.17.0",
"js-yaml": "^3.6.1",
"node-sass": "^3.7.0",
"postcss": "^5.0.19",
"postcss-assets": "^4.0.1",
"postcss-loader": "^0.9.1",
"postcss-svgo": "^2.1.2",
"sass-loader": "^3.2.0",
"style-loader": "^0.13.1",
"webpack": "^1.12.14"
},
"scripts": {
"build": "webpack --config webpack.config.babel.js --optimize-minimize",
"deploy": "gh-pages -d dist",
"watch": "webpack --config webpack.config.babel.js --watch"
},
"dependencies": {
"forerunnerdb": "^1.3.769",
"lodash": "^4.13.1",
"marked": "^0.3.5",
"react": "^15.1.0",
"react-dom": "^15.1.0",
"react-router": "^2.4.1"
}
}
58 changes: 58 additions & 0 deletions src/components/_form.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@

.question-form {
width: 650px;
margin: auto;
padding: 2em;
padding-bottom: 0;
margin-bottom: -2px;

&__results-info-text {
margin-bottom: .4em;
padding: 0 1em;
color: #333;

span {
font-size: .9em;
}
}

&__search-array {
display: flex;
line-height: 5;

[type="search"],
select {
flex: 0;
-moz-appearance: none;
-webkit-appearance: none;
margin: 0;
padding: 0 1.5em;
padding-bottom: 2px;
border: none;
border-radius: 0;
background-color: #eee;
background-repeat: no-repeat;
line-height: inherit;
font: inherit;

&:focus {
outline: none;
background-color: yellow;
}
}

[type="search"] {
flex-basis: 65%;
border-top-left-radius: 3px;
font-weight: bold;
}

select {
flex-basis: 35%;
border-left: 1px solid #ccc;
border-top-right-radius: 3px;
background-image: inline("./../assets/dropdown-arrow.svg");
background-position: calc(100% - 1.5em) 50%;
}
}
}
32 changes: 32 additions & 0 deletions src/components/_list.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@

.pagination,
.question-list {
position: relative;
width: 650px;
margin: auto;
padding: 0 2em;
z-index: 5;
}

.pagination {
@extend %bulletless-list;
display: flex;
flex-wrap: wrap;
margin-top: 2em;
text-align: right;

&__page {
flex-basis: 2em;
flex-shrink: 0;

a {
display: block;
cursor: pointer;
font-size: .8em;
}

&--current {
font-weight: bold;
}
}
}
27 changes: 27 additions & 0 deletions src/components/_load.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

@keyframes ticktock {
0% { transform: rotate(0); }
100% { transform: rotate(360deg); }
}

.loading {
position: absolute;
height: 200px;
width: 200px;
top: 0;
bottom: 0;
left: 0;
right: 0;
margin: auto;
text-align: center;
font-weight: bold;

&__spinner {
height: 200px;
width: 200px;
animation: ticktock 6s linear infinite;
background-image: inline("./../assets/gear.svg");
background-size: contain;
background-repeat: no-repeat;
}
}
Empty file added src/components/_main.scss
Empty file.
94 changes: 94 additions & 0 deletions src/components/_question.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@

.question {
border: 1px solid;

& + & {
border-top: none;
}

&:first-child {
border-top-left-radius: 3px;
border-top-right-radius: 3px;
}

&:last-child {
border-bottom-left-radius: 3px;
border-bottom-right-radius: 3px;
}

&--answered {
background-color: #e9fcea;

&, .question-id {
border-color: darken(#e9fcea, 10%);
}

.question-id {
color: darken(#e9fcea, 50%);
}
}

&--unanswered {
background-color: #fce9f0;

&, .question-id {
border-color: darken(#fce9f0, 10%);
}

.question-id {
color: darken(#fce9f0, 50%);
}
}

h2 {
display: none;
}
}

.question-header {
display: flex;
line-height: 5;
}

.question-details,
.question-id {
flex: 0;
padding: 0 1.5em;
}

.question-details {
@include inline-list;
flex-basis: 65%;
margin: 0;

&__date {}

&__authors {


ul {
@include inline-list(.5em);
}
}

&__answers {


ul {
@include inline-list(.5em);
}
}
}

.question-id {
flex-basis: 35%;
font-weight: bold;
border-left: 1px solid;
padding-left: 1.5em;
text-align: center;
}

.question-text {
padding: 1em 1.5em;
background-color: #fff;
}
34 changes: 34 additions & 0 deletions src/components/form.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@

import React from 'react';


export class Form extends React.Component {
render() {
return (
<div className="question-form">
<p className="question-form__results-info-text">
{this.props.resultCount}{`${this.props.resultCount == 1
? " αποτέλεσμα"
: " αποτελέσματα"}`}
</p>
<div className="question-form__search-array">
<input
type="search"
placeholder="Αναζήτηση"
defaultValue={this.props.initialSearchValue}
onChange={this.props.pushToValue}/>
<select
arial-label="Επιλογή τιμών"
onChange={this.props.pushToScope}
defaultValue={this.props.initialSearchScope}>
<option value="all">Όλα τα πεδία</option>
<option value="by">Ερωτώντες</option>
<option value="date">Ημερομηνία</option>
<option value="identifier">Αριθμός</option>
<option value="text">Κείμενο</option>
</select>
</div>
</div>
);
}
}
39 changes: 39 additions & 0 deletions src/components/list.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@

import React from 'react';
import {Question} from './question.js';


class Pager extends React.Component {
render() {
return (
<ul className="pagination">
{this.props.pages.map(page => (
<li className={`pagination__page${this.props.page == page
? " pagination__page--current"
: ""}`}
key={page}>
<a data-page={page} onClick={this.props.pushToPage}>{page + 1}</a>
</li>
))}
</ul>
);
}
}

export class List extends React.Component {
render() {
return (
<div>
<div className="question-list">
{this.props.questions.map(question => (
<Question key={question._id} data={question}/>
))}
</div>
<Pager
page={this.props.page}
pages={this.props.pages}
pushToPage={this.props.pushToPage}/>
</div>
);
}
}
19 changes: 19 additions & 0 deletions src/components/load.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

import _ from 'lodash';
import React from 'react';


const pepTalk = [
'Βάσταξε', 'Πόμινε', 'Υπομονήν τζαι κράτην'
];

export class Load extends React.Component {
render() {
return (
<div className="loading">
<div className="loading__spinner"/>
{pepTalk[_.random(pepTalk.length - 1)]}
</div>
);
}
}
Loading

0 comments on commit 114b879

Please sign in to comment.