Skip to content
This repository was archived by the owner on Mar 9, 2021. It is now read-only.

Commit 59e2e60

Browse files
vinaypuppalZubair Ahmed
authored andcommitted
implement events loader (#132)
1 parent cf53478 commit 59e2e60

File tree

5 files changed

+83
-21
lines changed

5 files changed

+83
-21
lines changed

components/events/event-card.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,7 @@ export default props => (
9797
<Flex wrap>
9898
<Box fontSize={[12, 14, 16]} width={[1, 1, 0.38]} className="secondaryText" pr={1} mr={[0]} my={[1, 1, 0]}>
9999
<TimeIcon className="icons" />
100-
<span>
101-
{props.tense === 'past'
102-
? format(props.time, "ddd MMM Do 'YY")
103-
: format(props.time, "ddd MMM Do 'YY, h:mm A")}
104-
</span>
100+
<span>{format(props.time, "ddd MMM Do 'YY, h:mm A")}</span>
105101
</Box>
106102
<Box fontSize={[12, 14, 16]} width={[1, 1, 0.24]} className="secondaryText" pr={1} mx={[0]} my={[1, 1, 0]}>
107103
<AttendeesIcon className="icons" />
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import React from 'react';
2+
import ContentLoader from 'react-content-loader';
3+
import styled from 'react-emotion';
4+
import { space } from 'styled-system';
5+
import { Flex } from 'grid-emotion';
6+
7+
import { breakpoints, graySecondary } from '../../utils/base.styles';
8+
9+
const EventLoader = styled(Flex)`
10+
${space};
11+
border: 1px solid ${graySecondary};
12+
margin: 32px 0;
13+
min-height: 120px;
14+
${breakpoints.md} {
15+
padding-right: 15px;
16+
}
17+
${breakpoints.sm} {
18+
padding-right: 15px;
19+
}
20+
${breakpoints.xs} {
21+
padding-right: 15px;
22+
}
23+
`;
24+
25+
export default () => (
26+
<EventLoader my={[3]} wrap>
27+
<ContentLoader width="100%" speed={4} primaryColor={'#f3f3f3'} secondaryColor={'#ecebeb'}>
28+
<rect x="0" y="0" rx="5" ry="5" width="200" height="132" />
29+
<rect x="207" y="7" rx="4" ry="4" width="550" height="20" />
30+
<rect x="210" y="54" rx="4" ry="4" width="300" height="15" />
31+
<rect x="210" y="100" rx="4" ry="4" width="120" height="15" />
32+
<rect x="355" y="100" rx="4" ry="4" width="120" height="15" />
33+
<rect x="503" y="100" rx="4" ry="4" width="120" height="15" />
34+
<rect x="636" y="74" rx="4" ry="4" width="120" height="40" />
35+
</ContentLoader>
36+
</EventLoader>
37+
);

package.json

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
"main": "index.js",
66
"scripts": {
77
"test": "xo && jest",
8-
"lint":
9-
"prettier 'utils/**/*.js' 'components/**/*.js' 'pages/**/*.js' 'lib/**/*.js' 'hocs/**/*.js' '*.js' --write && xo && markdownlint .",
8+
"lint": "prettier 'utils/**/*.js' 'components/**/*.js' 'pages/**/*.js' 'lib/**/*.js' 'hocs/**/*.js' '*.js' --write && xo && markdownlint .",
109
"precommit": "lint-staged",
1110
"analyze": "cross-env ANALYZE=1 next build",
1211
"dev": "cross-env NODE_ENV=development node server.js",
@@ -18,19 +17,32 @@
1817
},
1918
"xo": {
2019
"parser": "babel-eslint",
21-
"extends": ["prettier", "prettier/react", "plugin:react/recommended"],
22-
"env": ["browser", "node"],
20+
"extends": [
21+
"prettier",
22+
"prettier/react",
23+
"plugin:react/recommended"
24+
],
25+
"env": [
26+
"browser",
27+
"node"
28+
],
2329
"rules": {
2430
"linebreak-style": 0,
2531
"react/display-name": 0,
2632
"react/prop-types": 0
2733
},
2834
"space:": 2,
29-
"ignores": ["next.config.js"],
35+
"ignores": [
36+
"next.config.js"
37+
],
3038
"overrides": [
3139
{
3240
"files": "**/__tests__/*.test.js",
33-
"globals": ["describe", "it", "expect"]
41+
"globals": [
42+
"describe",
43+
"it",
44+
"expect"
45+
]
3446
}
3547
]
3648
},
@@ -41,8 +53,16 @@
4153
"jest --findRelatedTests",
4254
"git add"
4355
],
44-
"**/*.md": ["prettier", "markdownlint", "git add"],
45-
".github/CONTRIBUTING.md": ["doctoc", "prettier", "git add"]
56+
"**/*.md": [
57+
"prettier",
58+
"markdownlint",
59+
"git add"
60+
],
61+
".github/CONTRIBUTING.md": [
62+
"doctoc",
63+
"prettier",
64+
"git add"
65+
]
4666
},
4767
"dependencies": {
4868
"babel-plugin-emotion": "^8.0.10",
@@ -62,6 +82,7 @@
6282
"preact-emotion": "^8.0.10",
6383
"prop-types": "^15.5.10",
6484
"react": "^16.0.0",
85+
"react-content-loader": "^1.7.1",
6586
"react-dom": "^16.0.0",
6687
"react-emotion": "^8.0.10",
6788
"react-event-timeline": "^1.4.0",

pages/events.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import BannerSection from '../components/common/banner';
99
import { Container, SubTitle, Button } from '../utils/base.styles';
1010
import { baseEventsURL, futureEventsURL, pastEventsURL, imagePlaceholderURL } from '../utils/urls';
1111
import EventCard from '../components/events/event-card';
12+
import EventLoader from '../components/events/event-content-loader';
1213

1314
const EventsSection = styled.section`
1415
${space};
@@ -70,11 +71,9 @@ export default class Events extends React.Component {
7071

7172
renderEvents(events, loadLimit) {
7273
if (this.state.loading) {
73-
return (
74-
<SubTitle inverted color="#222">
75-
Loading..
76-
</SubTitle>
77-
);
74+
return [1, 2].map(i => {
75+
return <EventLoader key={i} />;
76+
});
7877
} else if (events.length === 0) {
7978
return (
8079
<SubTitle inverted color="#222">
@@ -132,6 +131,7 @@ export default class Events extends React.Component {
132131
}
133132

134133
render() {
134+
const { loading } = this.state;
135135
return (
136136
<Layout>
137137
<BannerSection title="Online & Offline Events" subTitle="Because you cannot change the world alone" />
@@ -143,7 +143,8 @@ export default class Events extends React.Component {
143143
Upcoming Events
144144
</h3>
145145
{this.renderEvents(this.state.futureEvents, this.state.futureEventsLoadLimit)}
146-
{this.renderLoadMoreButton(this.state.futureEvents.length, this.state.futureEventsLoadLimit, false)}
146+
{!loading &&
147+
this.renderLoadMoreButton(this.state.futureEvents.length, this.state.futureEventsLoadLimit, false)}
147148
</Box>
148149
</Flex>
149150
<Flex direction="column" align="center" justify="center">
@@ -152,7 +153,8 @@ export default class Events extends React.Component {
152153
Recent Events
153154
</h3>
154155
{this.renderEvents(this.state.pastEvents, this.state.pastEventsLoadLimit)}
155-
{this.renderLoadMoreButton(this.state.pastEvents.length, this.state.pastEventsLoadLimit, true)}
156+
{!loading &&
157+
this.renderLoadMoreButton(this.state.pastEvents.length, this.state.pastEventsLoadLimit, true)}
156158
</Box>
157159
</Flex>
158160
</Container>

yarn.lock

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1046,7 +1046,7 @@ babel-register@^6.26.0:
10461046
mkdirp "^0.5.1"
10471047
source-map-support "^0.4.15"
10481048

1049-
babel-runtime@6.26.0, babel-runtime@^6.18.0, babel-runtime@^6.22.0, babel-runtime@^6.26.0:
1049+
babel-runtime@6.26.0, babel-runtime@^6.18.0, babel-runtime@^6.22.0, babel-runtime@^6.26.0, babel-runtime@^6.6.1:
10501050
version "6.26.0"
10511051
resolved "https://registry.yarnpkg.com/babel-runtime/-/babel-runtime-6.26.0.tgz#965c7058668e82b55d7bfe04ff2337bc8b5647fe"
10521052
dependencies:
@@ -5834,6 +5834,12 @@ rc@~1.1.6:
58345834
minimist "^1.2.0"
58355835
strip-json-comments "~2.0.1"
58365836

5837+
react-content-loader@^1.7.1:
5838+
version "1.7.1"
5839+
resolved "https://registry.yarnpkg.com/react-content-loader/-/react-content-loader-1.7.1.tgz#e6e18adbf632829fd56ba6fe558d16d2a5a00af9"
5840+
dependencies:
5841+
babel-runtime "^6.6.1"
5842+
58375843
react-deep-force-update@^2.1.1:
58385844
version "2.1.1"
58395845
resolved "https://registry.yarnpkg.com/react-deep-force-update/-/react-deep-force-update-2.1.1.tgz#8ea4263cd6455a050b37445b3f08fd839d86e909"

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy