Skip to content

Commit cd8ae32

Browse files
authored
Merge pull request #33 from lynnlo/styling-cities
Added Styling to City Links
2 parents ac4233a + 4fd02ac commit cd8ae32

File tree

5 files changed

+68
-8
lines changed

5 files changed

+68
-8
lines changed

.babelrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{ "presets": ["next/babel"], "plugins": [["styled-components", { "ssr": true }]] }

components/cities.js

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import React from 'react';
2+
import PropTypes from 'prop-types';
3+
import Link from 'next/link';
4+
import styled from 'styled-components';
5+
6+
const CityDiv = styled.div`
7+
display: flex;
8+
flex-direction: column;
9+
justify-content: center;
10+
align-items: center;
11+
background-color: #ff686b;
12+
border: 1px solid #e6e6e6;
13+
border-radius: 3px;
14+
box-shadow: 0 4px 4px rgba(0,0,0,0.5);
15+
padding: 30px;
16+
cursor: pointer;
17+
transition: filter 0.2s ease-in-out;
18+
19+
&:hover {
20+
filter: brightness(1.2);
21+
}
22+
23+
&:active {
24+
filter: brightness(0.8);
25+
}
26+
`;
27+
28+
export default class Cities extends React.Component {
29+
static propTypes = {
30+
href: PropTypes.string.isRequired,
31+
city_event: PropTypes.object.isRequired,
32+
}
33+
34+
constructor(props) {
35+
super(props);
36+
}
37+
38+
render() {
39+
const { href, city_event } = this.props;
40+
41+
return (
42+
<CityDiv onClick={()=> {window.location = href}}>
43+
<h3> {city_event.name} </h3>
44+
</CityDiv>
45+
);
46+
}
47+
}

next.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,8 @@ module.exports = {
1111

1212
return config;
1313
},
14+
compiler: {
15+
styledComponents: true
16+
},
1417
port: 8001,
1518
};

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
"version": "0.1.0",
44
"private": true,
55
"scripts": {
6-
"dev": "next dev",
7-
"build": "next build",
6+
"dev": "NODE_OPTIONS=--openssl-legacy-provider next dev",
7+
"build": "NODE_OPTIONS=--openssl-legacy-provider next build",
88
"start": "NODE_ENV=production node server.js"
99
},
1010
"dependencies": {

pages/index.js

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@ import React from 'react';
22
import PropTypes from 'prop-types';
33
import Link from 'next/link';
44
import Srnd from '../server/srndApi';
5+
import Cities from '../components/cities';
6+
import styled from 'styled-components';
7+
8+
const CityContainer = styled.div`
9+
display: flex;
10+
flex-direction: row;
11+
flex-wrap: wrap;
12+
justify-content: center;
13+
align-items: center;
14+
gap: 10px;
15+
`;
516

617
export default class Index extends React.Component {
718
static propTypes = {
@@ -21,13 +32,11 @@ export default class Index extends React.Component {
2132
<div>
2233
<h1>CodeDay Present</h1>
2334
<p>Pick a city...</p>
24-
<ul>
25-
{events.map((event) => (
26-
<li>
27-
<Link href={`/e/${event.id}`}>{event.name}</Link>
28-
</li>
35+
<CityContainer>
36+
{events.map((event, index) => (
37+
<Cities key={index} href={`/e/${event.id}`} city_event={event} />
2938
))}
30-
</ul>
39+
</CityContainer>
3140
</div>
3241
);
3342
}

0 commit comments

Comments
 (0)