├── .prettierrc.json
├── nodemon.json
├── .prettierignore
├── .eslintignore
├── client
├── public
│ ├── robots.txt
│ ├── favicon.ico
│ ├── logo192.png
│ ├── logo512.png
│ ├── manifest.json
│ └── index.html
├── src
│ ├── assets
│ │ ├── img
│ │ │ └── espresso.jpg
│ │ ├── fonts
│ │ │ ├── Roboto-Light.ttf
│ │ │ ├── Roboto-Medium.ttf
│ │ │ ├── Roboto-Regular.ttf
│ │ │ └── ArchivoBlack-Regular.ttf
│ │ └── icons
│ │ │ ├── arrowright.svg
│ │ │ ├── softdrinks.svg
│ │ │ ├── arrowleft.svg
│ │ │ ├── time.svg
│ │ │ ├── searchInput.svg
│ │ │ ├── chat.svg
│ │ │ ├── profile.svg
│ │ │ ├── searchInput2.svg
│ │ │ ├── progress1.svg
│ │ │ ├── progress2.svg
│ │ │ ├── search.svg
│ │ │ ├── pricetag.svg
│ │ │ ├── wine.svg
│ │ │ ├── cancel.svg
│ │ │ ├── coffeetea.svg
│ │ │ ├── beveragetype.svg
│ │ │ ├── calendar.svg
│ │ │ ├── thirst.svg
│ │ │ ├── share.svg
│ │ │ ├── tastingpackage.svg
│ │ │ ├── mixeddrinks.svg
│ │ │ ├── beer.svg
│ │ │ ├── cocktail.svg
│ │ │ ├── country.svg
│ │ │ ├── language.svg
│ │ │ ├── logo.svg
│ │ │ └── brand.svg
│ ├── App.test.js
│ ├── api
│ │ ├── getEvents.js
│ │ ├── getEvent.js
│ │ └── getFilteredEvents.js
│ ├── pages
│ │ ├── EventPage.stories.js
│ │ ├── SearchPage.stories.js
│ │ ├── SplashPage.js
│ │ ├── EventDetailsPage.js
│ │ ├── SearchPage.js
│ │ └── EventPage.js
│ ├── stories
│ │ ├── SplashMain.stories.js
│ │ ├── SplashFooter.stories.js
│ │ ├── Footer.stories.js
│ │ ├── Searchbar.stories.js
│ │ ├── EventDetails.stories.js
│ │ ├── SearchPageHeader.stories.js
│ │ ├── EventDetailsHeader.stories.js
│ │ ├── EventDetailsFooter.stories.js
│ │ ├── EventCard.stories.js
│ │ └── EventList.stories.js
│ ├── setupTests.js
│ ├── components
│ │ ├── Button.js
│ │ ├── EventDetailsFooter.js
│ │ ├── HighlightableButton.js
│ │ ├── SearchPageHeader.js
│ │ ├── Searchbar.js
│ │ ├── EventList.js
│ │ ├── EventDetailsHeader.js
│ │ ├── SplashFooter.js
│ │ ├── FilterListCountry.js
│ │ ├── SplashMain.js
│ │ ├── FilterListBeverages.js
│ │ ├── Footer.js
│ │ ├── EventCard.js
│ │ └── EventDetails.js
│ ├── index.js
│ ├── hooks
│ │ └── useAsync.js
│ ├── App.js
│ ├── GlobalStyles.js
│ └── serviceWorker.js
├── .storybook
│ ├── main.js
│ └── preview.js
├── .gitignore
├── package.json
└── README.md
├── .github
├── ISSUE_TEMPLATE
│ └── user-story.md
└── workflows
│ └── node.js.yml
├── .eslintrc.json
├── server.js
├── README.md
├── LICENSE
├── package.json
├── .gitignore
└── db.json
/.prettierrc.json:
--------------------------------------------------------------------------------
1 | {}
2 |
--------------------------------------------------------------------------------
/nodemon.json:
--------------------------------------------------------------------------------
1 | {
2 | "ignore": ["client/*"]
3 | }
4 |
--------------------------------------------------------------------------------
/.prettierignore:
--------------------------------------------------------------------------------
1 | # Ignore artifacts:
2 | build
3 | coverage
--------------------------------------------------------------------------------
/.eslintignore:
--------------------------------------------------------------------------------
1 | **/node_modules/
2 | **/build/
3 | **/storybook-static/
--------------------------------------------------------------------------------
/client/public/robots.txt:
--------------------------------------------------------------------------------
1 | # https://www.robotstxt.org/robotstxt.html
2 | User-agent: *
3 | Disallow:
4 |
--------------------------------------------------------------------------------
/client/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rheimers/tastingApp/HEAD/client/public/favicon.ico
--------------------------------------------------------------------------------
/client/public/logo192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rheimers/tastingApp/HEAD/client/public/logo192.png
--------------------------------------------------------------------------------
/client/public/logo512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rheimers/tastingApp/HEAD/client/public/logo512.png
--------------------------------------------------------------------------------
/client/src/assets/img/espresso.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rheimers/tastingApp/HEAD/client/src/assets/img/espresso.jpg
--------------------------------------------------------------------------------
/client/src/assets/fonts/Roboto-Light.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rheimers/tastingApp/HEAD/client/src/assets/fonts/Roboto-Light.ttf
--------------------------------------------------------------------------------
/client/src/assets/fonts/Roboto-Medium.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rheimers/tastingApp/HEAD/client/src/assets/fonts/Roboto-Medium.ttf
--------------------------------------------------------------------------------
/client/src/assets/fonts/Roboto-Regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rheimers/tastingApp/HEAD/client/src/assets/fonts/Roboto-Regular.ttf
--------------------------------------------------------------------------------
/client/src/assets/fonts/ArchivoBlack-Regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rheimers/tastingApp/HEAD/client/src/assets/fonts/ArchivoBlack-Regular.ttf
--------------------------------------------------------------------------------
/client/src/App.test.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import { render } from "@testing-library/react";
3 | import App from "./App";
4 |
5 | test("renders App", () => {
6 | render();
7 | });
8 |
--------------------------------------------------------------------------------
/client/src/api/getEvents.js:
--------------------------------------------------------------------------------
1 | export const getEvents = async () => {
2 | const response = await fetch("/api/events");
3 | if (!response.ok) {
4 | throw response;
5 | }
6 |
7 | const result = await response.json();
8 | return result;
9 | };
10 |
--------------------------------------------------------------------------------
/client/src/api/getEvent.js:
--------------------------------------------------------------------------------
1 | export const getEvent = async (id) => {
2 | const response = await fetch(`/api/events/${id}`);
3 | if (!response.ok) {
4 | throw response;
5 | }
6 |
7 | const result = await response.json();
8 | return result;
9 | };
10 |
--------------------------------------------------------------------------------
/client/src/pages/EventPage.stories.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import EventPage from "../pages/EventPage";
3 |
4 | export default {
5 | title: "EventPage",
6 | component: EventPage,
7 | };
8 |
9 | export const EventHomePage = () => ;
10 |
--------------------------------------------------------------------------------
/client/.storybook/main.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | stories: ["../src/**/*.stories.mdx", "../src/**/*.stories.@(js|jsx|ts|tsx)"],
3 | addons: [
4 | "@storybook/addon-links",
5 | "@storybook/addon-essentials",
6 | "@storybook/preset-create-react-app",
7 | ],
8 | };
9 |
--------------------------------------------------------------------------------
/client/src/pages/SearchPage.stories.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import SearchPage from "../pages/SearchPage";
3 |
4 | export default {
5 | title: "SearchPage",
6 | component: SearchPage,
7 | };
8 |
9 | export const SearchResultsPage = () => ;
10 |
--------------------------------------------------------------------------------
/client/src/stories/SplashMain.stories.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import SplashMain from "../components/SplashMain";
3 |
4 | export default {
5 | title: "SplashMain",
6 | component: SplashMain,
7 | };
8 |
9 | export const Splash1Main = () => ;
10 |
--------------------------------------------------------------------------------
/client/src/api/getFilteredEvents.js:
--------------------------------------------------------------------------------
1 | export const getFilteredEvents = async (query) => {
2 | const response = await fetch(`/api/events?q=${query}`);
3 | if (!response.ok) {
4 | throw response;
5 | }
6 |
7 | const result = await response.json();
8 | return result;
9 | };
10 |
--------------------------------------------------------------------------------
/client/src/stories/SplashFooter.stories.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import SplashFooter from "../components/SplashFooter";
3 |
4 | export default {
5 | title: "SplashFooter",
6 | component: SplashFooter,
7 | };
8 |
9 | export const Splash1Footer = () => ;
10 |
--------------------------------------------------------------------------------
/client/src/setupTests.js:
--------------------------------------------------------------------------------
1 | // jest-dom adds custom jest matchers for asserting on DOM nodes.
2 | // allows you to do things like:
3 | // expect(element).toHaveTextContent(/react/i)
4 | // learn more: https://github.com/testing-library/jest-dom
5 | import "@testing-library/jest-dom/extend-expect";
6 |
--------------------------------------------------------------------------------
/client/src/stories/Footer.stories.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import Footer from "../components/Footer";
3 |
4 | export default {
5 | title: "Footer",
6 | component: Footer,
7 | };
8 |
9 | const Template = () => ;
10 |
11 | export const MainFooter = Template.bind({});
12 |
--------------------------------------------------------------------------------
/client/src/assets/icons/arrowright.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/client/src/assets/icons/softdrinks.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/client/src/assets/icons/arrowleft.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/client/src/stories/Searchbar.stories.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import Searchbar from "../components/Searchbar";
3 |
4 | export default {
5 | title: "Searchbar",
6 | component: Searchbar,
7 | };
8 |
9 | const Template = () => ;
10 |
11 | export const MainSearchbar = Template.bind({});
12 |
--------------------------------------------------------------------------------
/client/src/stories/EventDetails.stories.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import EventDetails from "../components/EventDetails";
3 |
4 | export default {
5 | title: "EventDetails",
6 | component: EventDetails,
7 | };
8 |
9 | const Template = () => ;
10 |
11 | export const EventDetailsBox = Template.bind({});
12 |
--------------------------------------------------------------------------------
/client/src/stories/SearchPageHeader.stories.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import SearchPageHeader from "../components/SearchPageHeader";
3 |
4 | export default {
5 | title: "SearchPageHeader",
6 | component: SearchPageHeader,
7 | };
8 |
9 | const Template = () => ;
10 |
11 | export const SearchHeader = Template.bind({});
12 |
--------------------------------------------------------------------------------
/client/src/assets/icons/time.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/client/src/assets/icons/searchInput.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/client/src/stories/EventDetailsHeader.stories.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import EventDetailsHeader from "../components/EventDetailsHeader";
3 |
4 | export default {
5 | title: "EventDetailsHeader",
6 | component: EventDetailsHeader,
7 | };
8 |
9 | const Template = () => ;
10 |
11 | export const DetailsHeader = Template.bind({});
12 |
--------------------------------------------------------------------------------
/client/src/stories/EventDetailsFooter.stories.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import EventDetailsFooter from "../components/EventDetailsFooter";
3 |
4 | export default {
5 | title: "EventDetailsFooter",
6 | component: EventDetailsFooter,
7 | };
8 |
9 | const Template = () => ;
10 |
11 | export const DetailsFooterButton = Template.bind({});
12 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/user-story.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: User story
3 | about: agile feature description
4 | title: ''
5 | labels: user story
6 | assignees: rheimers
7 |
8 | ---
9 |
10 | # User story
11 | As a
12 | I want to
13 | so I can
14 |
15 | # Description
16 |
17 | # Notes / Links
18 |
19 | # Acceptance Criteria
20 | - [ ]
21 | - [ ]
22 | - [ ]
23 | - [ ]
24 | - [ ]
25 |
--------------------------------------------------------------------------------
/client/src/assets/icons/chat.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/client/src/components/Button.js:
--------------------------------------------------------------------------------
1 | import styled from "@emotion/styled";
2 |
3 | const Button = styled.button`
4 | padding: 0.8rem 1rem 0.8rem;
5 | border-radius: 0.8rem;
6 | min-width: 284px;
7 | max-width: 400px;
8 | background-color: #ffa200;
9 | color: var(--font-color-white);
10 | text-transform: uppercase;
11 | border: none;
12 | `;
13 |
14 | export default Button;
15 |
--------------------------------------------------------------------------------
/client/src/assets/icons/profile.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/client/src/assets/icons/searchInput2.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/client/.storybook/preview.js:
--------------------------------------------------------------------------------
1 | import GlobalStyles from "../src/GlobalStyles";
2 | import React from "react";
3 | export const parameters = {
4 | actions: { argTypesRegex: "^on[A-Z].*" },
5 | layout: "fullscreen",
6 | };
7 | const withGlobalStyles = (Story, context) => {
8 | return (
9 | <>
10 |
11 | >
12 | );
13 | };
14 | export const decorators = [withGlobalStyles];
15 |
--------------------------------------------------------------------------------
/client/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 | /.pnp
6 | .pnp.js
7 |
8 | # testing
9 | /coverage
10 |
11 | # production
12 | /build
13 |
14 | # misc
15 | .DS_Store
16 | .env.local
17 | .env.development.local
18 | .env.test.local
19 | .env.production.local
20 |
21 | npm-debug.log*
22 | yarn-debug.log*
23 | yarn-error.log*
24 |
25 | /storybook-static
--------------------------------------------------------------------------------
/client/src/assets/icons/progress1.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/client/src/assets/icons/progress2.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/client/src/assets/icons/search.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/client/src/assets/icons/pricetag.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/client/src/components/EventDetailsFooter.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import styled from "@emotion/styled";
3 | import Button from "./Button.js";
4 |
5 | const FooterContainer = styled.footer`
6 | display: flex;
7 | justify-content: center;
8 | margin: 1rem 0;
9 | position: fixed;
10 | left: 0;
11 | bottom: 0;
12 | width: 100%;
13 | `;
14 |
15 | export default function Footer() {
16 | return (
17 |
18 |
19 |
20 | );
21 | }
22 |
--------------------------------------------------------------------------------
/client/src/assets/icons/wine.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/client/src/assets/icons/cancel.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/client/src/assets/icons/coffeetea.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/client/src/assets/icons/beveragetype.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/client/src/index.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import ReactDOM from "react-dom";
3 | import App from "./App";
4 | import * as serviceWorker from "./serviceWorker";
5 |
6 | ReactDOM.render(
7 |
8 |
9 | ,
10 | document.getElementById("root")
11 | );
12 |
13 | // If you want your app to work offline and load faster, you can change
14 | // unregister() to register() below. Note this comes with some pitfalls.
15 | // Learn more about service workers: https://bit.ly/CRA-PWA
16 | serviceWorker.unregister();
17 |
--------------------------------------------------------------------------------
/client/src/assets/icons/calendar.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/client/public/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "short_name": "drinks & stories",
3 | "name": "drinks & stories",
4 | "icons": [
5 | {
6 | "src": "favicon.ico",
7 | "sizes": "64x64 32x32 24x24 16x16",
8 | "type": "image/x-icon"
9 | },
10 | {
11 | "src": "logo192.png",
12 | "type": "image/png",
13 | "sizes": "192x192"
14 | },
15 | {
16 | "src": "logo512.png",
17 | "type": "image/png",
18 | "sizes": "512x512"
19 | }
20 | ],
21 | "start_url": ".",
22 | "display": "standalone",
23 | "theme_color": "#000000",
24 | "background_color": "#ffffff"
25 | }
26 |
--------------------------------------------------------------------------------
/.eslintrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "env": {
3 | "browser": true,
4 | "commonjs": true,
5 | "es6": true,
6 | "node": true
7 | },
8 | "extends": [
9 | "react-app",
10 | "eslint:recommended",
11 | "plugin:react/recommended",
12 | "prettier"
13 | ],
14 | "parserOptions": {
15 | "ecmaFeatures": {
16 | "jsx": true
17 | },
18 | "ecmaVersion": 12,
19 | "sourceType": "module"
20 | },
21 | "rules": {
22 | "no-unused-vars": [
23 | "warn",
24 | {
25 | "vars": "all",
26 | "args": "all",
27 | "ignoreRestSiblings": true
28 | }
29 | ]
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/client/src/assets/icons/thirst.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/client/src/pages/SplashPage.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import styled from "@emotion/styled";
3 | import SplashFooter from "../components/SplashFooter";
4 | import SplashMain from "../components/SplashMain";
5 | import PropTypes from "prop-types";
6 |
7 | const Container = styled.div`
8 | display: flex;
9 | `;
10 |
11 | function SplashPage({ page }) {
12 | return (
13 |
14 |
15 |
16 |
17 |
18 | );
19 | }
20 |
21 | export default SplashPage;
22 |
23 | SplashPage.propTypes = {
24 | page: PropTypes.number.isRequired,
25 | };
26 |
--------------------------------------------------------------------------------
/client/src/assets/icons/share.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/client/src/assets/icons/tastingpackage.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/client/src/assets/icons/mixeddrinks.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/client/src/hooks/useAsync.js:
--------------------------------------------------------------------------------
1 | import { useState, useEffect } from "react";
2 |
3 | function useAsync(asyncFunction, args) {
4 | const [data, setData] = useState(null);
5 | const [loading, setLoading] = useState(false);
6 | const [error, setError] = useState(false);
7 |
8 | useEffect(() => {
9 | const doFetch = async () => {
10 | try {
11 | setLoading(true);
12 | setError(false);
13 | setData(null);
14 | const data = await asyncFunction(args);
15 | setData(data);
16 | } catch (error) {
17 | setError(true);
18 | } finally {
19 | setLoading(false);
20 | }
21 | };
22 | doFetch();
23 | }, [asyncFunction, args]);
24 |
25 | return { data, loading, error };
26 | }
27 |
28 | export default useAsync;
29 |
--------------------------------------------------------------------------------
/client/src/stories/EventCard.stories.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import EventCard from "../components/EventCard";
3 |
4 | export default {
5 | title: "EventCard",
6 | component: EventCard,
7 | };
8 |
9 | export const WineEventCard = () => (
10 |
15 | );
16 | export const BeerEventCard = () => (
17 |
22 | );
23 |
--------------------------------------------------------------------------------
/client/src/assets/icons/beer.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.github/workflows/node.js.yml:
--------------------------------------------------------------------------------
1 | # This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
2 | # For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
3 |
4 | name: Node.js CI
5 |
6 | on:
7 | push:
8 | branches: [ master ]
9 | pull_request:
10 | branches: [ master ]
11 |
12 | jobs:
13 | build:
14 |
15 | runs-on: ubuntu-latest
16 |
17 | strategy:
18 | matrix:
19 | node-version: [10.x, 12.x, 14.x]
20 |
21 | steps:
22 | - uses: actions/checkout@v2
23 | - name: Use Node.js ${{ matrix.node-version }}
24 | uses: actions/setup-node@v1
25 | with:
26 | node-version: ${{ matrix.node-version }}
27 | - run: npm ci
28 | - run: npm run build --if-present
29 | - run: npm test
30 |
--------------------------------------------------------------------------------
/server.js:
--------------------------------------------------------------------------------
1 | const express = require("express");
2 | const path = require("path");
3 | const jsonServer = require("json-server");
4 |
5 | const app = express();
6 | const port = process.env.PORT || 3001;
7 | const router = jsonServer.router("db.json");
8 | const middlewares = jsonServer.defaults();
9 |
10 | // Serve any static files
11 | app.use(express.static(path.join(__dirname, "client/build")));
12 | app.use(
13 | "/storybook",
14 | express.static(path.join(__dirname, "client/storybook-static"))
15 | );
16 |
17 | app.use(
18 | jsonServer.rewriter({
19 | "/api/*": "/$1",
20 | })
21 | );
22 |
23 | app.use(router);
24 | app.use(middlewares);
25 |
26 | //Handle React routing, return all requests to React app
27 | app.get("/", (request, response) => {
28 | response.send("Hello World!");
29 | });
30 |
31 | app.listen(port, () => {
32 | console.log(`Server listening at http://localhost:${port}`);
33 | });
34 |
--------------------------------------------------------------------------------
/client/src/components/HighlightableButton.js:
--------------------------------------------------------------------------------
1 | import React, { useState } from "react";
2 | import PropTypes from "prop-types";
3 | import styled from "@emotion/styled";
4 |
5 | function HighlightableButton({ children, className }) {
6 | const [clicked, setClicked] = useState(false);
7 | return (
8 |
14 | );
15 | }
16 |
17 | const StyledHighlightableButton = styled(HighlightableButton)`
18 | background: transparent;
19 | border: none;
20 | &.active {
21 | background: var(--clr-primary);
22 | }
23 | &:focus {
24 | outline: none;
25 | }
26 | `;
27 |
28 | export default StyledHighlightableButton;
29 | HighlightableButton.propTypes = {
30 | children: PropTypes.object.isRequired,
31 | className: PropTypes.string.isRequired,
32 | };
33 |
--------------------------------------------------------------------------------
/client/src/assets/icons/cocktail.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/client/src/assets/icons/country.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/client/src/components/SearchPageHeader.js:
--------------------------------------------------------------------------------
1 | import React, { useState } from "react";
2 | import Searchbar from "../components/Searchbar";
3 | import styled from "@emotion/styled";
4 | import ArrowLeftSrc from "../assets/icons/arrowleft.svg";
5 | import { useHistory } from "react-router-dom";
6 |
7 | const Header = styled.header`
8 | display: flex;
9 | overflow: hidden;
10 | `;
11 |
12 | function SearchPageHeader() {
13 | const history = useHistory();
14 | const [query, setQuery] = useState("");
15 | function handleSubmit(event) {
16 | event.preventDefault();
17 | history.push(`/search?q=${query}`);
18 | }
19 | return (
20 |
21 |
22 | setQuery(event.target.value)}
25 | onSubmit={handleSubmit}
26 | onClear={() => setQuery("")}
27 | />
28 |
29 | );
30 | }
31 |
32 | export default SearchPageHeader;
33 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # 
2 |
3 | Offers online drinks tastings from across the world – live, with and without alcohol.
4 |
5 | **THIS IS A NON-COMMERCIAL-PROJECT AS FINAL THESIS FOR MY WEB DEVELOPER BOOTCAMP AT [neue fische](https://www.neuefische.de/)**
6 |
7 | drinks & stories is an app where beverage producers, distributors, or simply enthusiasts host virtual drinks tastings live. Ranging from soft drinks, mixed drinks, wine, beer to tea, and coffee — there is an event for every taste.
8 |
9 | Current version: 1.0 || 11.10.2020
10 |
11 | ## 📲 Design and layout infos
12 |
13 | The app is designed and laid out for smartphone screens, so adjust the settings in your view accordingly to IPhone 5 or 6/7/8.
14 |
15 | ## 🔧 Development
16 |
17 | ### Requirements
18 |
19 | Node.js and npm
20 |
21 | ### 👨💻 Install all dependencies
22 |
23 | `npm install`
24 |
25 | Since there is a postinstall, the system automatically searches the client folder and installs the required dependencies there, too.
26 |
27 | ### 💻 Run dev server with:
28 |
29 | `npm run dev`
30 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020 rheimers
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/client/src/pages/EventDetailsPage.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import EventDetailsHeader from "../components/EventDetailsHeader";
3 | import EventDetails from "../components/EventDetails";
4 | import EventDetailsFooter from "../components/EventDetailsFooter";
5 | import { getEvent } from "../api/getEvent";
6 | import useAsync from "../hooks/useAsync";
7 | import { useParams } from "react-router-dom";
8 |
9 | EventDetailsPage.propTypes = {};
10 |
11 | function EventDetailsPage() {
12 | const { id } = useParams();
13 | const { data: event } = useAsync(getEvent, id);
14 | return (
15 |
16 |
17 | {event && (
18 |
27 | )}
28 |
29 |
30 | );
31 | }
32 |
33 | export default EventDetailsPage;
34 |
--------------------------------------------------------------------------------
/client/src/App.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import { BrowserRouter as Router, Switch, Route } from "react-router-dom";
3 | import GlobalStyles from "./GlobalStyles";
4 | import EventPage from "./pages/EventPage";
5 | import SearchPage from "./pages/SearchPage";
6 | import styled from "@emotion/styled";
7 | import EventDetailsPage from "./pages/EventDetailsPage";
8 | import SplashPage from "./pages/SplashPage";
9 |
10 | const AppContainer = styled.div`
11 | margin-bottom: 6.25rem;
12 | `;
13 |
14 | function App() {
15 | return (
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 | );
39 | }
40 |
41 | export default App;
42 |
--------------------------------------------------------------------------------
/client/src/pages/SearchPage.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import useAsync from "../hooks/useAsync";
3 | import Footer from "../components/Footer";
4 | import styled from "@emotion/styled";
5 | import { useLocation } from "react-router-dom";
6 | import { getFilteredEvents } from "../api/getFilteredEvents";
7 | import EventCard from "../components/EventCard";
8 | import SearchPageHeader from "../components/SearchPageHeader";
9 |
10 | const Container = styled.div`
11 | display: flex;
12 | flex-flow: column;
13 | margin-left: 1.3rem;
14 | `;
15 |
16 | function SearchPage() {
17 | const useQuery = () => {
18 | return new URLSearchParams(useLocation().search);
19 | };
20 | let query = useQuery();
21 | const { data: events } = useAsync(getFilteredEvents, query.get("q"));
22 |
23 | return (
24 |
25 |
26 | {events?.map((event) => (
27 |
35 | ))}
36 |
37 |
38 |
39 | );
40 | }
41 |
42 | export default SearchPage;
43 |
--------------------------------------------------------------------------------
/client/src/assets/icons/language.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/client/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "client",
3 | "version": "0.1.0",
4 | "private": true,
5 | "dependencies": {
6 | "@babel/core": "^7.11.6",
7 | "@emotion/core": "^10.0.35",
8 | "@emotion/styled": "^10.0.27",
9 | "@storybook/addon-actions": "^6.0.21",
10 | "@storybook/addon-essentials": "^6.0.21",
11 | "@storybook/addon-links": "^6.0.21",
12 | "@storybook/node-logger": "^6.0.21",
13 | "@storybook/preset-create-react-app": "^3.1.4",
14 | "@storybook/react": "^6.0.21",
15 | "@testing-library/jest-dom": "^4.2.4",
16 | "@testing-library/react": "^9.5.0",
17 | "@testing-library/user-event": "^7.2.1",
18 | "babel-loader": "^8.1.0",
19 | "prop-types": "^15.7.2",
20 | "react": "^16.13.1",
21 | "react-dom": "^16.13.1",
22 | "react-is": "^16.13.1",
23 | "react-router-dom": "^5.2.0",
24 | "react-scripts": "3.4.3"
25 | },
26 | "scripts": {
27 | "start": "react-scripts start",
28 | "build": "react-scripts build",
29 | "test": "react-scripts test",
30 | "eject": "react-scripts eject",
31 | "storybook": "start-storybook -p 6006 -s public",
32 | "build-storybook": "build-storybook -s public"
33 | },
34 | "browserslist": {
35 | "production": [
36 | ">0.2%",
37 | "not dead",
38 | "not op_mini all"
39 | ],
40 | "development": [
41 | "last 1 chrome version",
42 | "last 1 firefox version",
43 | "last 1 safari version"
44 | ]
45 | },
46 | "proxy": "http://localhost:3001"
47 | }
48 |
--------------------------------------------------------------------------------
/client/src/components/Searchbar.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import styled from "@emotion/styled";
3 | import SearchIcon from "../assets/icons/searchInput2.svg";
4 | import PropTypes from "prop-types";
5 | import CancelIcon from "../assets/icons/cancel.svg";
6 |
7 | const InputForm = styled.form`
8 | display: flex;
9 | justify-content: center;
10 | position: relative;
11 | `;
12 |
13 | const Input = styled.input`
14 | margin: 2.6rem;
15 | padding: 0.8rem 1rem 0.8rem 50px;
16 | border: 1px solid #dddddd;
17 | border-radius: 11px;
18 | min-width: 284px;
19 | background-image: url(${SearchIcon});
20 | background-repeat: no-repeat;
21 | background-position: 0.75rem 0.625rem;
22 | font: var(--font-robotolight);
23 | `;
24 |
25 | const ClearButton = styled.div`
26 | position: absolute;
27 | top: 3.4rem;
28 | right: 3.8rem;
29 | background: transparent;
30 | border: none;
31 | &:focus {
32 | outline: none;
33 | }
34 | `;
35 |
36 | export default function Searchbar({ onSubmit, onClear, ...props }) {
37 | const handleClear = (event) => {
38 | event.preventDefault();
39 | onClear();
40 | };
41 | return (
42 |
43 |
44 |
45 |
46 |
47 |
48 | );
49 | }
50 |
51 | Searchbar.propTypes = {
52 | onSubmit: PropTypes.func.isRequired,
53 | onClear: PropTypes.func.isRequired,
54 | };
55 |
--------------------------------------------------------------------------------
/client/src/components/EventList.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import styled from "@emotion/styled";
3 | import PropTypes from "prop-types";
4 | import EventCard from "./EventCard";
5 |
6 | const Container = styled.div`
7 | display: flex;
8 | flex-flow: column;
9 | justify-content: space-around;
10 | h2 {
11 | margin: 0.8em 0 0.5em;
12 | }
13 | `;
14 |
15 | const ListContainerScroller = styled.div`
16 | width: 100%;
17 | overflow: auto;
18 | `;
19 | const ListContainer = styled.div`
20 | display: flex;
21 | & > *:not(:first-of-type) {
22 | margin-left: 1.2em;
23 | }
24 | `;
25 |
26 | export default function EventList({ title, events, category }) {
27 | const filteredEvents =
28 | category && events
29 | ? events.filter((event) => event.category === category)
30 | : events;
31 | return (
32 |
33 | {title}
34 |
35 |
36 |
37 | {filteredEvents?.map((event) => (
38 |
46 | ))}
47 |
48 |
49 |
50 | );
51 | }
52 |
53 | EventList.propTypes = {
54 | title: PropTypes.string.isRequired,
55 | events: PropTypes.array,
56 | category: PropTypes.string,
57 | };
58 |
--------------------------------------------------------------------------------
/client/src/pages/EventPage.js:
--------------------------------------------------------------------------------
1 | import React, { useState } from "react";
2 | import Searchbar from "../components/Searchbar";
3 | import EventList from "../components/EventList";
4 | import FilterListBeverages from "../components/FilterListBeverages";
5 | import { getEvents } from "../api/getEvents";
6 | import useAsync from "../hooks/useAsync";
7 | import Footer from "../components/Footer";
8 | import styled from "@emotion/styled";
9 | import { useHistory } from "react-router-dom";
10 | import FilterListCountry from "../components/FilterListCountry";
11 |
12 | const Container = styled.div`
13 | display: flex;
14 | flex-flow: column;
15 | margin-left: 1rem;
16 | `;
17 |
18 | function EventPage() {
19 | const history = useHistory();
20 | const [query, setQuery] = useState("");
21 | const { data: events } = useAsync(getEvents);
22 | function handleSubmit(event) {
23 | event.preventDefault();
24 | history.push(`/search?q=${query}`);
25 | }
26 |
27 | return (
28 |
29 | setQuery(event.target.value)}
32 | onSubmit={handleSubmit}
33 | onClear={() => setQuery("")}
34 | />
35 |
36 |
41 |
42 |
43 |
44 |
45 | );
46 | }
47 |
48 | export default EventPage;
49 |
--------------------------------------------------------------------------------
/client/src/assets/icons/logo.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/client/src/components/EventDetailsHeader.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import styled from "@emotion/styled";
3 | import ThirstIcon from "../assets/icons/thirst.svg";
4 | import ArrowLeftIcon from "../assets/icons/arrowleft.svg";
5 | import ShareIcon from "../assets/icons/share.svg";
6 | import { Link } from "react-router-dom";
7 | import HighlightableButton from "./HighlightableButton";
8 | import PropTypes from "prop-types";
9 |
10 | const Header = styled.header`
11 | display: grid;
12 | grid-template-columns: 50px auto 100px;
13 | grid-template-rows: repeat(4, 25%);
14 | background-image: linear-gradient(rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 0.5)),
15 | url(${({ imgSrc }) => imgSrc});
16 | background-repeat: no-repeat;
17 | background-position: 50% 30%;
18 | background-size: 100%;
19 | height: 100%;
20 | min-height: 174px;
21 |
22 | & > .backButton {
23 | grid-column: 1/2;
24 | grid-row: 2/3;
25 | justify-self: center;
26 | margin-left: 1rem;
27 | }
28 | & > .buttonsContainer {
29 | grid-column: 3/4;
30 | grid-row: 1/2;
31 | align-self: center;
32 | justify-self: center;
33 | margin-top: 1rem;
34 | }
35 | `;
36 |
37 | export default function DetailsHeader({ imgSrc }) {
38 | return (
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 | );
55 | }
56 | DetailsHeader.propTypes = {
57 | imgSrc: PropTypes.string,
58 | };
59 |
--------------------------------------------------------------------------------
/client/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
12 |
13 |
17 |
18 |
27 | drinks & stories
28 |
29 |
30 |
31 |
32 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/client/src/components/SplashFooter.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import styled from "@emotion/styled";
3 | import Progress1Src from "../assets/icons/progress1.svg";
4 | import Progress2Src from "../assets/icons/progress2.svg";
5 | import ArrowRightSrc from "../assets/icons/arrowright.svg";
6 | import { Link } from "react-router-dom";
7 | import PropTypes from "prop-types";
8 |
9 | const FooterContainer = styled.footer`
10 | display: flex;
11 | flex-direction: column;
12 | position: fixed;
13 | left: 0;
14 | bottom: 0;
15 | width: 100vw;
16 | -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
17 | `;
18 |
19 | const FooterIcons = styled.nav`
20 | padding: 1em 0.5em;
21 | margin: 0 1.5em;
22 | display: flex;
23 | justify-content: space-between;
24 | `;
25 |
26 | const FooterIcon = styled.div`
27 | img {
28 | margin-bottom: 0.3rem;
29 | }
30 | div {
31 | margin-top: 0.5rem;
32 | }
33 | `;
34 |
35 | const Footer1 = () => (
36 | <>
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 | >
46 | );
47 |
48 | const Footer2 = () => (
49 | <>
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 | >
59 | );
60 |
61 | export default function Footer({ page }) {
62 | return (
63 |
64 | {page === 1 ? (
65 |
66 | {" "}
67 |
68 |
69 | ) : (
70 |
71 |
72 |
73 | )}
74 |
75 | );
76 | }
77 |
78 | Footer.propTypes = {
79 | page: PropTypes.number,
80 | };
81 |
--------------------------------------------------------------------------------
/client/src/components/FilterListCountry.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import styled from "@emotion/styled";
3 | import PropTypes from "prop-types";
4 |
5 | const Container = styled.div`
6 | display: flex;
7 | flex-flow: column;
8 | justify-content: space-around;
9 | h2 {
10 | margin: 0.8em 0 0.5em;
11 | }
12 | `;
13 |
14 | const ListContainerScroller = styled.div`
15 | width: 100%;
16 | overflow: auto;
17 | `;
18 | const ListContainer = styled.div`
19 | display: flex;
20 | & > *:not(:first-of-type) {
21 | margin-left: 1.2em;
22 | }
23 | div:first-of-type {
24 | color: var(--highlight-clr-category1);
25 | }
26 | div:nth-of-type(2) {
27 | color: var(--highlight-clr-category2);
28 | }
29 | div:nth-of-type(3) {
30 | color: var(--highlight-clr-category3);
31 | }
32 | div:nth-of-type(4) {
33 | color: var(--highlight-clr-category4);
34 | }
35 | div:nth-of-type(5) {
36 | color: var(--highlight-clr-category5);
37 | }
38 | `;
39 |
40 | const CountryContainer = styled.div`
41 | display: flex;
42 | justify-content: center;
43 | align-items: center;
44 | background: var(--contrast-dk);
45 | padding: 10px;
46 | min-width: 90px;
47 | height: 80px;
48 | border-radius: 10px;
49 | first-of-type {
50 | font: var(--highlight-clr-category1);
51 | }
52 | `;
53 |
54 | export default function FilterListCountry({ title }) {
55 | return (
56 |
57 | {title}
58 |
59 |
60 |
61 | Australia
62 | Belgium
63 | Colombia
64 | France
65 | Spain
66 |
67 |
68 |
69 | );
70 | }
71 |
72 | FilterListCountry.propTypes = {
73 | title: PropTypes.string.isRequired,
74 | };
75 |
--------------------------------------------------------------------------------
/client/src/assets/icons/brand.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/client/src/components/SplashMain.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import styled from "@emotion/styled";
3 | import LogoIconSrc from "../assets/icons/logo.svg";
4 | import PropTypes from "prop-types";
5 |
6 | const Container = styled.div`
7 | display: flex;
8 | flex-direction: column;
9 | margin-left: 1.5rem;
10 | margin-top: 5rem;
11 |
12 | img {
13 | margin-right: 0.3rem;
14 | margin-bottom: 0.8rem;
15 | }
16 |
17 | h1 {
18 | color: var(--highlight-clr-category4);
19 | }
20 |
21 | p {
22 | font-family: var(--font-archivoblack);
23 | font-size: 1.7rem;
24 | }
25 | span {
26 | }
27 | `;
28 |
29 | const Header = styled.header`
30 | display: flex;
31 | align-items: center;
32 | flex-direction: column;
33 | `;
34 |
35 | const Main = styled.div`
36 | margin-top: 2rem;
37 | `;
38 |
39 | const Main2 = styled.div`
40 | margin-top: 4rem;
41 | margin-bottom: 3rem;
42 | `;
43 |
44 | const SplashContent1 = () => (
45 | <>
46 |
47 |
48 | drinks & stories
49 |
50 |
51 | offers
52 | online
53 | drinks tastings
54 | from
55 | across the world
56 | live
57 | with & without
58 | alcohol.
59 |
60 | >
61 | );
62 |
63 | const SplashContent2 = () => (
64 | <>
65 |
66 | So make
67 | yourself
68 | comfortable
69 | at home,
70 | invite friends and
71 | travel the world
72 | with
73 |
74 |
75 |
76 | drinks & stories
77 |
78 | >
79 | );
80 |
81 | export default function SplashMain({ page }) {
82 | return (
83 |
84 | {page === 1 ? : }
85 |
86 | );
87 | }
88 |
89 | SplashMain.propTypes = {
90 | page: PropTypes.number.isRequired,
91 | };
92 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "tasting-app",
3 | "private": true,
4 | "version": "1.0.0",
5 | "description": "The app offers beverage tastings from across the world",
6 | "main": "index.js",
7 | "scripts": {
8 | "postinstall": "cd client && npm install",
9 | "build": "cd client && npm run build && npm run build-storybook",
10 | "storybook": "cd client && npm run storybook",
11 | "test": "npm run lint && cd client && npm test",
12 | "lint": "eslint . --ext .js",
13 | "prettify": "prettier --write .",
14 | "dev": "concurrently \"npm run server\" \"npm run client\"",
15 | "client": "cd client && npm start",
16 | "server": "nodemon server.js",
17 | "start": "node server.js"
18 | },
19 | "repository": {
20 | "type": "git",
21 | "url": "git+https://github.com/rheimers/tastingApp.git"
22 | },
23 | "keywords": [],
24 | "author": "",
25 | "license": "ISC",
26 | "bugs": {
27 | "url": "https://github.com/rheimers/tastingApp/issues"
28 | },
29 | "homepage": "https://github.com/rheimers/tastingApp#readme",
30 | "devDependencies": {
31 | "@typescript-eslint/eslint-plugin": "^2.34.0",
32 | "@typescript-eslint/parser": "^2.34.0",
33 | "babel-eslint": "^10.1.0",
34 | "concurrently": "^5.3.0",
35 | "eslint": "^6.6.0",
36 | "eslint-config-prettier": "^6.11.0",
37 | "eslint-config-react-app": "^5.2.1",
38 | "eslint-plugin-flowtype": "^4.7.0",
39 | "eslint-plugin-import": "^2.22.0",
40 | "eslint-plugin-jsx-a11y": "^6.3.1",
41 | "eslint-plugin-react": "^7.20.6",
42 | "eslint-plugin-react-hooks": "^2.5.1",
43 | "husky": "^4.3.0",
44 | "lint-staged": "^10.3.0",
45 | "nodemon": "^2.0.4",
46 | "prettier": "^2.1.1"
47 | },
48 | "husky": {
49 | "hooks": {
50 | "pre-commit": "lint-staged",
51 | "pre-push": "CI=true npm test"
52 | }
53 | },
54 | "lint-staged": {
55 | "*.js": "eslint --cache --fix",
56 | "*.{js,css,md}": "prettier --write"
57 | },
58 | "dependencies": {
59 | "express": "^4.17.1",
60 | "json-server": "^0.16.1"
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/client/src/components/FilterListBeverages.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import styled from "@emotion/styled";
3 | import PropTypes from "prop-types";
4 | import BeerIcon from "../assets/icons/beer.svg";
5 | import WineIcon from "../assets/icons/wine.svg";
6 | import CoffeeTeaIcon from "../assets/icons/coffeetea.svg";
7 | import MixedDrinksIcon from "../assets/icons/mixeddrinks.svg";
8 | import SoftDrinksIcon from "../assets/icons/softdrinks.svg";
9 |
10 | const Container = styled.div`
11 | display: flex;
12 | flex-flow: column;
13 | justify-content: space-around;
14 | h2 {
15 | margin: 0.8em 0 0.5em;
16 | }
17 | `;
18 |
19 | const ListContainerScroller = styled.div`
20 | width: 100%;
21 | overflow: auto;
22 | `;
23 | const ListContainer = styled.div`
24 | display: flex;
25 | & > *:not(:first-of-type) {
26 | margin-left: 1.2em;
27 | }
28 | `;
29 |
30 | const IconContainer = styled.div`
31 | img {
32 | background: var(--contrast-dk);
33 | padding: 10px;
34 | width: 60px;
35 | height: 60px;
36 | border-radius: 10px;
37 | }
38 | `;
39 |
40 | export default function FilterListBeverages({ title }) {
41 | return (
42 |
43 | {title}
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 | );
66 | }
67 |
68 | FilterListBeverages.propTypes = {
69 | title: PropTypes.string.isRequired,
70 | };
71 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 | npm-debug.log*
5 | yarn-debug.log*
6 | yarn-error.log*
7 | lerna-debug.log*
8 |
9 | # Diagnostic reports (https://nodejs.org/api/report.html)
10 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
11 |
12 | # Runtime data
13 | pids
14 | *.pid
15 | *.seed
16 | *.pid.lock
17 |
18 | # Directory for instrumented libs generated by jscoverage/JSCover
19 | lib-cov
20 |
21 | # Coverage directory used by tools like istanbul
22 | coverage
23 | *.lcov
24 |
25 | # nyc test coverage
26 | .nyc_output
27 |
28 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
29 | .grunt
30 |
31 | # Bower dependency directory (https://bower.io/)
32 | bower_components
33 |
34 | # node-waf configuration
35 | .lock-wscript
36 |
37 | # Compiled binary addons (https://nodejs.org/api/addons.html)
38 | build/Release
39 |
40 | # Dependency directories
41 | node_modules/
42 | jspm_packages/
43 |
44 | # TypeScript v1 declaration files
45 | typings/
46 |
47 | # TypeScript cache
48 | *.tsbuildinfo
49 |
50 | # Optional npm cache directory
51 | .npm
52 |
53 | # Optional eslint cache
54 | .eslintcache
55 |
56 | # Microbundle cache
57 | .rpt2_cache/
58 | .rts2_cache_cjs/
59 | .rts2_cache_es/
60 | .rts2_cache_umd/
61 |
62 | # Optional REPL history
63 | .node_repl_history
64 |
65 | # Output of 'npm pack'
66 | *.tgz
67 |
68 | # Yarn Integrity file
69 | .yarn-integrity
70 |
71 | # dotenv environment variables file
72 | .env
73 | .env.test
74 |
75 | # parcel-bundler cache (https://parceljs.org/)
76 | .cache
77 |
78 | # Next.js build output
79 | .next
80 |
81 | # Nuxt.js build / generate output
82 | .nuxt
83 | dist
84 |
85 | # Gatsby files
86 | .cache/
87 | # Comment in the public line in if your project uses Gatsby and *not* Next.js
88 | # https://nextjs.org/blog/next-9-1#public-directory-support
89 | # public
90 |
91 | # vuepress build output
92 | .vuepress/dist
93 |
94 | # Serverless directories
95 | .serverless/
96 |
97 | # FuseBox cache
98 | .fusebox/
99 |
100 | # DynamoDB Local files
101 | .dynamodb/
102 |
103 | # TernJS port file
104 | .tern-port
105 |
--------------------------------------------------------------------------------
/client/src/components/Footer.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import styled from "@emotion/styled";
3 | import SearchIcon from "../assets/icons/search.svg";
4 | import ThirstIcon from "../assets/icons/thirst.svg";
5 | import CalendarIcon from "../assets/icons/calendar.svg";
6 | import ChatIcon from "../assets/icons/chat.svg";
7 | import ProfileIcon from "../assets/icons/profile.svg";
8 |
9 | const FooterContainer = styled.footer`
10 | display: flex;
11 | flex-direction: column;
12 | position: fixed;
13 | left: 0;
14 | bottom: 0;
15 | width: 100vw;
16 | background: var(--contrast-dk);
17 | font-family: var(--font-robotolight);
18 | `;
19 |
20 | const FooterDelimitation = styled.div`
21 | height: 0.01em;
22 | background-color: var(--contrast-lt);
23 | `;
24 |
25 | const FooterIcons = styled.nav`
26 | padding: 1em 0.5em;
27 | margin: 0 1em;
28 | display: flex;
29 | justify-content: space-between;
30 | `;
31 |
32 | const FooterIcon = styled.div`
33 | text-align: center;
34 | flex-basis: 0;
35 | font-size: 0.8rem;
36 |
37 | img {
38 | margin-bottom: 3px;
39 | }
40 | div {
41 | margin-top: 1px;
42 | }
43 | &:hover {
44 | background-color: var(--clr-primary);
45 | border-radius: 5px;
46 | }
47 | `;
48 |
49 | export default function Footer() {
50 | return (
51 |
52 |
53 |
54 |
55 |
56 | Search
57 |
58 |
59 |
60 |
61 | Thirst
62 |
63 |
64 |
65 |
66 | Tastings
67 |
68 |
69 |
70 |
71 | Chat
72 |
73 |
74 |
75 |
76 | Profile
77 |
78 |
79 |
80 | );
81 | }
82 |
--------------------------------------------------------------------------------
/client/src/GlobalStyles.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import { Global, css } from "@emotion/core";
3 | import ArchivoBlack from "./assets/fonts/ArchivoBlack-Regular.ttf";
4 | import Roboto from "./assets/fonts/Roboto-Regular.ttf";
5 | import RobotoLight from "./assets/fonts/Roboto-Light.ttf";
6 |
7 | const GlobalStyles = () => {
8 | return (
9 |
81 | );
82 | };
83 |
84 | export default GlobalStyles;
85 |
--------------------------------------------------------------------------------
/client/src/components/EventCard.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import styled from "@emotion/styled";
3 | import PropTypes from "prop-types";
4 | import { Link } from "react-router-dom";
5 |
6 | const Card = styled.div`
7 | display: grid;
8 | grid-template-columns: repeat(4, 25%);
9 | grid-template-rows: 45%;
10 | background-image: linear-gradient(rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 0.3)),
11 | url(${({ imgSrc }) => imgSrc});
12 | background-size: cover;
13 | background-repeat: no-repeat;
14 | min-width: 108px;
15 | height: 93px;
16 | border-radius: 12px;
17 | h2 {
18 | color: ${(props) => {
19 | switch (props.category) {
20 | case "Wine":
21 | return "var(--highlight-clr-category1)";
22 | case "Coffee & Tea":
23 | return "var(--highlight-clr-category2)";
24 | case "Beer":
25 | return "var(--highlight-clr-category3)";
26 | case "Mixed drinks":
27 | return "var(--highlight-clr-category4)";
28 | case "Soft drinks":
29 | return "var(--highlight-clr-category5)";
30 |
31 | default:
32 | return "var(--font-color-white)";
33 | }
34 | }};
35 |
36 | grid-row: 3;
37 | grid-column: 1 / 5;
38 | font: 11px/9px var(--font-archivoblack);
39 | text-transform: uppercase;
40 | margin: 5px;
41 | }
42 | flex: 1 1 0px;
43 | max-width: 120px;
44 | `;
45 |
46 | const DateContainer = styled.div`
47 | grid-row: 1 / 2;
48 | grid-column: 1 / 2;
49 | background-color: white;
50 | border-radius: 2px;
51 | text-align: center;
52 | color: var(--clr-primary);
53 | margin: 4px;
54 | font-size: 50%;
55 | padding: 1px;
56 | div:first-of-type {
57 | color: var(--contrast-dk);
58 | text-transform: uppercase;
59 | }
60 | div:nth-of-type(2) {
61 | font-size: 12px;
62 | }
63 | div:nth-of-type(3) {
64 | text-transform: uppercase;
65 | }
66 | `;
67 | const days = ["Sun", "Mon", "Tu", "Wed", "Thu", "Fr", "Sat"];
68 | const months = [
69 | "Jan",
70 | "Feb",
71 | "Mar",
72 | "Apr",
73 | "May",
74 | "June",
75 | "Jul",
76 | "Aug",
77 | "Sep",
78 | "Oct",
79 | "Nov",
80 | "Dec",
81 | ];
82 | export default function EventCard({ id, title, imgSrc, date, category }) {
83 | return (
84 |
85 |
86 |
87 | {days[date.getDay()]}
88 | {date.getDate()}
89 | {months[date.getMonth()]}
90 |
91 | {title}
92 |
93 |
94 | );
95 | }
96 |
97 | EventCard.propTypes = {
98 | id: PropTypes.string.isRequired,
99 | title: PropTypes.string.isRequired,
100 | category: PropTypes.string.isRequired,
101 | imgSrc: PropTypes.string.isRequired,
102 | date: PropTypes.instanceOf(Date).isRequired,
103 | };
104 |
--------------------------------------------------------------------------------
/client/README.md:
--------------------------------------------------------------------------------
1 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
2 |
3 | ## Available Scripts
4 |
5 | In the project directory, you can run:
6 |
7 | ### `npm start`
8 |
9 | Runs the app in the development mode.
10 | Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
11 |
12 | The page will reload if you make edits.
13 | You will also see any lint errors in the console.
14 |
15 | ### `npm test`
16 |
17 | Launches the test runner in the interactive watch mode.
18 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
19 |
20 | ### `npm run build`
21 |
22 | Builds the app for production to the `build` folder.
23 | It correctly bundles React in production mode and optimizes the build for the best performance.
24 |
25 | The build is minified and the filenames include the hashes.
26 | Your app is ready to be deployed!
27 |
28 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
29 |
30 | ### `npm run eject`
31 |
32 | **Note: this is a one-way operation. Once you `eject`, you can’t go back!**
33 |
34 | If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
35 |
36 | Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
37 |
38 | You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
39 |
40 | ## Learn More
41 |
42 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
43 |
44 | To learn React, check out the [React documentation](https://reactjs.org/).
45 |
46 | ### Code Splitting
47 |
48 | This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting
49 |
50 | ### Analyzing the Bundle Size
51 |
52 | This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size
53 |
54 | ### Making a Progressive Web App
55 |
56 | This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app
57 |
58 | ### Advanced Configuration
59 |
60 | This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration
61 |
62 | ### Deployment
63 |
64 | This section has moved here: https://facebook.github.io/create-react-app/docs/deployment
65 |
66 | ### `npm run build` fails to minify
67 |
68 | This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify
69 |
--------------------------------------------------------------------------------
/db.json:
--------------------------------------------------------------------------------
1 | {
2 | "events": [
3 | {
4 | "id": "1",
5 | "title": "Riesling with Pete",
6 | "date": "2020-10-13T06:00:23.263Z",
7 | "imgSrc": "https://images.unsplash.com/photo-1591902318851-0073633a96a3?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=400&q=60",
8 | "category": "Wine",
9 | "host": "Pete Smith",
10 | "position": "Host & Producer",
11 | "country": "Australia, Clare Valley",
12 | "tastingpackage": "A 6-pack with a selection of Pete's most outstanding Rieslings",
13 | "language": "English",
14 | "price": "89 EUR",
15 | "typeTEST": "Wine Tasting",
16 | "typeTEST2": "Tasting Australia"
17 | },
18 | {
19 | "id": "2",
20 | "title": "Teatime with Anna",
21 | "date": "2020-10-15T03:12:23.263Z",
22 | "imgSrc": "https://images.unsplash.com/photo-1502302926530-87742e2c00b9?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1050&q=80",
23 | "category": "Coffee & Tea",
24 | "host": "Anna Chauffour",
25 | "position": "Host & Enthusiast",
26 | "country": "France",
27 | "tastingpackage": "3 x 20 g of devine fairtrade black teas",
28 | "language": "French",
29 | "price": "39 EUR",
30 | "typeTEST": "Tea Tasting",
31 | "typeTEST2": "Tasting France"
32 | },
33 | {
34 | "id": "3",
35 | "title": "Juices with Max",
36 | "date": "2020-10-16T04:12:23.263Z",
37 | "imgSrc": "https://images.unsplash.com/photo-1566618670541-94d6eafefe2b?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=634&q=80",
38 | "category": "Soft drinks",
39 | "host": "Max Perez",
40 | "position": "Host & Distributor",
41 | "country": "Colombia",
42 | "tastingpackage": "A 6-pack of Colombia's best and typical juices",
43 | "language": "English",
44 | "price": "49 EUR",
45 | "typeTEST": "Juice Tasting",
46 | "typeTEST2": "Tasting Colombia"
47 | },
48 | {
49 | "id": "4",
50 | "title": "Craft Beer with Bianca",
51 | "date": "2020-10-21T05:12:23.263Z",
52 | "imgSrc": "https: //images.unsplash.com/photo-1583228189114-bd0b24aa01c9?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1050&q=80",
53 | "category": "Beer",
54 | "host": "Bianca Leroy",
55 | "position": "Host & Producer",
56 | "country": "Belgium",
57 | "tastingpackage": "A discover set of 8 Craft Beers",
58 | "language": "English",
59 | "price": "49 EUR",
60 | "typeTEST": "Beer Tasting",
61 | "typeTEST2": "Tasting Belgium"
62 | },
63 | {
64 | "id": "5",
65 | "title": "Cocktail Hour with Mario",
66 | "date": "2020-10-24T06:12:23.263Z",
67 | "imgSrc": "https://images.unsplash.com/photo-1547650125-48358abce41b?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=400&q=60",
68 | "category": "Mixed drinks",
69 | "host": "Mario Sánchez",
70 | "position": "Host & Barkeeper",
71 | "country": "Spanish",
72 | "tastingpackage": "Ingredients for 3 top spanish drinks",
73 | "language": "English",
74 | "price": "79 EUR",
75 | "typeTEST": "Cocktail Tasting",
76 | "typeTEST2": "Tasting Spain"
77 | }
78 | ]
79 | }
80 |
--------------------------------------------------------------------------------
/client/src/components/EventDetails.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import styled from "@emotion/styled";
3 | import PropTypes from "prop-types";
4 | import LanguageIcon from "../assets/icons/language.svg";
5 | import PriceIcon from "../assets/icons/pricetag.svg";
6 | import TimeIcon from "../assets/icons/time.svg";
7 | import CountryIcon from "../assets/icons/country.svg";
8 | import CategoryIcon from "../assets/icons/beveragetype.svg";
9 | import TastingPackageIcon from "../assets/icons/tastingpackage.svg";
10 |
11 | const EventDetailsContainer = styled.div`
12 | display: flex;
13 | flex-direction: column;
14 | margin-left: 0.8rem;
15 |
16 | h2 {
17 | margin: 0.8rem 1rem 0.5rem;
18 | color: ${(props) => {
19 | switch (props.category) {
20 | case "Wine":
21 | return "var(--highlight-clr-category1)";
22 | case "Coffee & Tea":
23 | return "var(--highlight-clr-category2)";
24 | case "Beer":
25 | return "var(--highlight-clr-category3)";
26 | case "Mixed drinks":
27 | return "var(--highlight-clr-category4)";
28 | case "Soft drinks":
29 | return "var(--highlight-clr-category5)";
30 |
31 | default:
32 | return "var(--font-color-white)";
33 | }
34 | }};
35 | }
36 | `;
37 |
38 | const EventDetailsList = styled.ul`
39 | display: flex;
40 | flex-direction: column;
41 | overflow: auto;
42 | padding-inline-start: 0.8rem;
43 | list-style: none;
44 | margin: 1rem;
45 | img {
46 | background: var(--contrast-dk);
47 | padding: 10px;
48 | width: 50px;
49 | height: 50px;
50 | border-radius: 10px;
51 | }
52 | li {
53 | display: flex;
54 | align-items: center;
55 | justify-content: start;
56 | margin-bottom: 0.5rem;
57 | }
58 | small {
59 | margin: 0 0.2rem 0 1.5rem;
60 | }
61 | `;
62 |
63 | const days = ["Sun", "Mon", "Tu", "Wed", "Thu", "Fr", "Sat"];
64 | const months = [
65 | "Jan",
66 | "Feb",
67 | "Mar",
68 | "Apr",
69 | "May",
70 | "June",
71 | "Jul",
72 | "Aug",
73 | "Sep",
74 | "Oct",
75 | "Nov",
76 | "Dec",
77 | ];
78 |
79 | function EventDetails({
80 | title,
81 | date,
82 | country,
83 | category,
84 | language,
85 | price,
86 | tastingpackage,
87 | }) {
88 | return (
89 |
90 | {title}
91 |
92 |
93 |
94 |
95 | {days[date.getDay()]},
96 | {date.getDate()}
97 | {months[date.getMonth()]},
98 | {date.getHours()} pm CEST
99 |
100 |
101 |
102 |
103 | {country}
104 |
105 |
106 |
107 | {category}
108 |
109 |
110 |
111 | {tastingpackage}
112 |
113 |
114 |
115 | {price}
116 |
117 |
118 |
119 | {language}
120 |
121 |
122 |
123 | );
124 | }
125 |
126 | export default EventDetails;
127 |
128 | EventDetails.propTypes = {
129 | title: PropTypes.string.isRequired,
130 | category: PropTypes.string.isRequired,
131 | country: PropTypes.string.isRequired,
132 | language: PropTypes.string.isRequired,
133 | tastingpackage: PropTypes.string.isRequired,
134 | price: PropTypes.string.isRequired,
135 | date: PropTypes.instanceOf(Date).isRequired,
136 | };
137 |
--------------------------------------------------------------------------------
/client/src/stories/EventList.stories.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import EventList from "../components/EventList";
3 |
4 | export default {
5 | title: "EventList",
6 | component: EventList,
7 | };
8 |
9 | export const UpcomingEvents = () => (
10 | <>
11 |
12 |
13 | >
14 | );
15 | const items = [
16 | {
17 | title: `Riesling with Pete`,
18 | date: "2020-10-22T15:12:23.263Z",
19 | imgSrc:
20 | "https://images.unsplash.com/photo-1591902318851-0073633a96a3?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=400&q=60",
21 | },
22 | {
23 | title: `Riesling with Pete`,
24 | date: "2020-10-22T15:12:23.263Z",
25 | imgSrc:
26 | "https://images.unsplash.com/photo-1591902318851-0073633a96a3?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=400&q=60",
27 | },
28 | {
29 | title: `Riesling with Pete`,
30 | date: "2020-10-22T15:12:23.263Z",
31 | imgSrc:
32 | "https://images.unsplash.com/photo-1591902318851-0073633a96a3?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=400&q=60",
33 | },
34 | {
35 | title: `Riesling with Pete`,
36 | date: "2020-10-22T15:12:23.263Z",
37 | imgSrc:
38 | "https://images.unsplash.com/photo-1591902318851-0073633a96a3?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=400&q=60",
39 | },
40 | {
41 | title: `Riesling with Pete`,
42 | date: "2020-10-22T15:12:23.263Z",
43 | imgSrc:
44 | "https://images.unsplash.com/photo-1591902318851-0073633a96a3?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=400&q=60",
45 | },
46 | {
47 | title: `Riesling with Pete`,
48 | date: "2020-10-22T15:12:23.263Z",
49 | imgSrc:
50 | "https://images.unsplash.com/photo-1591902318851-0073633a96a3?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=400&q=60",
51 | },
52 | {
53 | title: `Riesling with Pete`,
54 | date: "2020-10-22T15:12:23.263Z",
55 | imgSrc:
56 | "https://images.unsplash.com/photo-1591902318851-0073633a96a3?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=400&q=60",
57 | },
58 | {
59 | title: `Riesling with Pete`,
60 | date: "2020-10-22T15:12:23.263Z",
61 | imgSrc:
62 | "https://images.unsplash.com/photo-1591902318851-0073633a96a3?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=400&q=60",
63 | },
64 | {
65 | title: `Riesling with Pete`,
66 | date: "2020-10-22T15:12:23.263Z",
67 | imgSrc:
68 | "https://images.unsplash.com/photo-1591902318851-0073633a96a3?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=400&q=60",
69 | },
70 | {
71 | title: `Riesling with Pete`,
72 | date: "2020-10-22T15:12:23.263Z",
73 | imgSrc:
74 | "https://images.unsplash.com/photo-1591902318851-0073633a96a3?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=400&q=60",
75 | },
76 | {
77 | title: `Riesling with Pete`,
78 | date: "2020-10-22T15:12:23.263Z",
79 | imgSrc:
80 | "https://images.unsplash.com/photo-1591902318851-0073633a96a3?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=400&q=60",
81 | },
82 | {
83 | title: `Riesling with Pete`,
84 | date: "2020-10-22T15:12:23.263Z",
85 | imgSrc:
86 | "https://images.unsplash.com/photo-1591902318851-0073633a96a3?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=400&q=60",
87 | },
88 | {
89 | title: `Riesling with Pete`,
90 | date: "2020-10-22T15:12:23.263Z",
91 | imgSrc:
92 | "https://images.unsplash.com/photo-1591902318851-0073633a96a3?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=400&q=60",
93 | },
94 | {
95 | title: `Riesling with Pete`,
96 | date: "2020-10-22T15:12:23.263Z",
97 | imgSrc:
98 | "https://images.unsplash.com/photo-1591902318851-0073633a96a3?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=400&q=60",
99 | },
100 | {
101 | title: `Riesling with Pete`,
102 | date: "2020-10-22T15:12:23.263Z",
103 | imgSrc:
104 | "https://images.unsplash.com/photo-1591902318851-0073633a96a3?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=400&q=60",
105 | },
106 | ];
107 |
--------------------------------------------------------------------------------
/client/src/serviceWorker.js:
--------------------------------------------------------------------------------
1 | // This optional code is used to register a service worker.
2 | // register() is not called by default.
3 |
4 | // This lets the app load faster on subsequent visits in production, and gives
5 | // it offline capabilities. However, it also means that developers (and users)
6 | // will only see deployed updates on subsequent visits to a page, after all the
7 | // existing tabs open on the page have been closed, since previously cached
8 | // resources are updated in the background.
9 |
10 | // To learn more about the benefits of this model and instructions on how to
11 | // opt-in, read https://bit.ly/CRA-PWA
12 |
13 | const isLocalhost = Boolean(
14 | window.location.hostname === "localhost" ||
15 | // [::1] is the IPv6 localhost address.
16 | window.location.hostname === "[::1]" ||
17 | // 127.0.0.0/8 are considered localhost for IPv4.
18 | window.location.hostname.match(
19 | /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/
20 | )
21 | );
22 |
23 | export function register(config) {
24 | if (process.env.NODE_ENV === "production" && "serviceWorker" in navigator) {
25 | // The URL constructor is available in all browsers that support SW.
26 | const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href);
27 | if (publicUrl.origin !== window.location.origin) {
28 | // Our service worker won't work if PUBLIC_URL is on a different origin
29 | // from what our page is served on. This might happen if a CDN is used to
30 | // serve assets; see https://github.com/facebook/create-react-app/issues/2374
31 | return;
32 | }
33 |
34 | window.addEventListener("load", () => {
35 | const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;
36 |
37 | if (isLocalhost) {
38 | // This is running on localhost. Let's check if a service worker still exists or not.
39 | checkValidServiceWorker(swUrl, config);
40 |
41 | // Add some additional logging to localhost, pointing developers to the
42 | // service worker/PWA documentation.
43 | navigator.serviceWorker.ready.then(() => {
44 | console.log(
45 | "This web app is being served cache-first by a service " +
46 | "worker. To learn more, visit https://bit.ly/CRA-PWA"
47 | );
48 | });
49 | } else {
50 | // Is not localhost. Just register service worker
51 | registerValidSW(swUrl, config);
52 | }
53 | });
54 | }
55 | }
56 |
57 | function registerValidSW(swUrl, config) {
58 | navigator.serviceWorker
59 | .register(swUrl)
60 | .then((registration) => {
61 | registration.onupdatefound = () => {
62 | const installingWorker = registration.installing;
63 | if (installingWorker == null) {
64 | return;
65 | }
66 | installingWorker.onstatechange = () => {
67 | if (installingWorker.state === "installed") {
68 | if (navigator.serviceWorker.controller) {
69 | // At this point, the updated precached content has been fetched,
70 | // but the previous service worker will still serve the older
71 | // content until all client tabs are closed.
72 | console.log(
73 | "New content is available and will be used when all " +
74 | "tabs for this page are closed. See https://bit.ly/CRA-PWA."
75 | );
76 |
77 | // Execute callback
78 | if (config && config.onUpdate) {
79 | config.onUpdate(registration);
80 | }
81 | } else {
82 | // At this point, everything has been precached.
83 | // It's the perfect time to display a
84 | // "Content is cached for offline use." message.
85 | console.log("Content is cached for offline use.");
86 |
87 | // Execute callback
88 | if (config && config.onSuccess) {
89 | config.onSuccess(registration);
90 | }
91 | }
92 | }
93 | };
94 | };
95 | })
96 | .catch((error) => {
97 | console.error("Error during service worker registration:", error);
98 | });
99 | }
100 |
101 | function checkValidServiceWorker(swUrl, config) {
102 | // Check if the service worker can be found. If it can't reload the page.
103 | fetch(swUrl, {
104 | headers: { "Service-Worker": "script" },
105 | })
106 | .then((response) => {
107 | // Ensure service worker exists, and that we really are getting a JS file.
108 | const contentType = response.headers.get("content-type");
109 | if (
110 | response.status === 404 ||
111 | (contentType != null && contentType.indexOf("javascript") === -1)
112 | ) {
113 | // No service worker found. Probably a different app. Reload the page.
114 | navigator.serviceWorker.ready.then((registration) => {
115 | registration.unregister().then(() => {
116 | window.location.reload();
117 | });
118 | });
119 | } else {
120 | // Service worker found. Proceed as normal.
121 | registerValidSW(swUrl, config);
122 | }
123 | })
124 | .catch(() => {
125 | console.log(
126 | "No internet connection found. App is running in offline mode."
127 | );
128 | });
129 | }
130 |
131 | export function unregister() {
132 | if ("serviceWorker" in navigator) {
133 | navigator.serviceWorker.ready
134 | .then((registration) => {
135 | registration.unregister();
136 | })
137 | .catch((error) => {
138 | console.error(error.message);
139 | });
140 | }
141 | }
142 |
--------------------------------------------------------------------------------