├── bg-moveon.svg ├── .eslintignore ├── .github └── moveon.gif ├── public ├── favicon.ico ├── notification.mp3 ├── favicon-16x16.png ├── favicon-32x32.png ├── images │ ├── moveon.gif │ └── touch │ │ ├── apple-icon.png │ │ ├── favicon-16x16.png │ │ ├── favicon-32x32.png │ │ ├── favicon-96x96.png │ │ ├── ms-icon-70x70.png │ │ ├── apple-icon-57x57.png │ │ ├── apple-icon-60x60.png │ │ ├── apple-icon-72x72.png │ │ ├── apple-icon-76x76.png │ │ ├── apple-touch-icon.png │ │ ├── ms-icon-150x150.png │ │ ├── ms-icon-310x310.png │ │ ├── android-icon-36x36.png │ │ ├── android-icon-48x48.png │ │ ├── android-icon-72x72.png │ │ ├── android-icon-96x96.png │ │ ├── apple-icon-114x114.png │ │ ├── apple-icon-120x120.png │ │ ├── apple-icon-144x144.png │ │ ├── apple-icon-152x152.png │ │ ├── apple-icon-180x180.png │ │ ├── android-icon-144x144.png │ │ ├── android-icon-192x192.png │ │ └── apple-icon-precomposed.png ├── move-on-logo-dark.png ├── move-on-logo-light.png ├── icons │ ├── play-arrow.svg │ ├── close.svg │ ├── check-circle.svg │ ├── medal.svg │ ├── moveon.svg │ ├── twitter.svg │ ├── github.svg │ ├── bkp │ │ ├── eye.svg │ │ └── body.svg │ ├── body.svg │ ├── level.svg │ ├── eye.svg │ ├── drinking.svg │ ├── level-up.svg │ ├── toilet.svg │ ├── body-2.svg │ ├── levelup.svg │ └── brain.svg ├── browserconfig.xml ├── bg-moveon.svg ├── move-on-logo.svg ├── manifest.json ├── logo-nlw.svg └── logo-full.svg ├── vercel.json ├── babel.config.js ├── next-env.d.ts ├── prettier.config.js ├── .editorconfig ├── src ├── styles │ ├── themes │ │ ├── dark.ts │ │ └── light.ts │ ├── styled.d.ts │ ├── components │ │ ├── CompletedChallenges.module.css │ │ ├── Profile.module.css │ │ ├── ExperienceBar.module.css │ │ ├── LevelUpModal.module.css │ │ ├── Sidebar.module.css │ │ ├── Countdown.module.css │ │ ├── ChallengeBox.module.css │ │ └── Score.module.css │ ├── pages │ │ ├── Home.module.css │ │ ├── Leaderboard.module.css │ │ └── Login.module.css │ └── global.ts ├── components │ ├── CompletedChallenges.tsx │ ├── ExperienceBar.tsx │ ├── Profile.tsx │ ├── ChallengeBox.tsx │ ├── Sidebar.tsx │ ├── Countdown.tsx │ ├── Score.tsx │ └── LevelUpModal.tsx ├── utils │ ├── usePersistedState.ts │ └── firebase.ts ├── pages │ ├── api │ │ ├── _lib │ │ │ ├── chromium.ts │ │ │ ├── chromeOptions.ts │ │ │ └── levelupTemplate.ts │ │ ├── auth │ │ │ └── [...nextauth].js │ │ └── levelup.ts │ ├── _app.tsx │ ├── login.tsx │ ├── leaderboard.tsx │ ├── _document.tsx │ └── index.tsx ├── _layouts │ └── LevelUpLayout.tsx └── contexts │ ├── CountdownContext.tsx │ └── ChallengesContext.tsx ├── .gitignore ├── next.config.js ├── tsconfig.json ├── .eslintrc.json ├── package.json ├── challenges.json ├── README.md ├── jest.config.ts └── LICENSE /bg-moveon.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .next 3 | .vercel 4 | /*.js 5 | -------------------------------------------------------------------------------- /.github/moveon.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schluters/nlw-move-on/HEAD/.github/moveon.gif -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schluters/nlw-move-on/HEAD/public/favicon.ico -------------------------------------------------------------------------------- /public/notification.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schluters/nlw-move-on/HEAD/public/notification.mp3 -------------------------------------------------------------------------------- /public/favicon-16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schluters/nlw-move-on/HEAD/public/favicon-16x16.png -------------------------------------------------------------------------------- /public/favicon-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schluters/nlw-move-on/HEAD/public/favicon-32x32.png -------------------------------------------------------------------------------- /public/images/moveon.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schluters/nlw-move-on/HEAD/public/images/moveon.gif -------------------------------------------------------------------------------- /public/move-on-logo-dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schluters/nlw-move-on/HEAD/public/move-on-logo-dark.png -------------------------------------------------------------------------------- /public/move-on-logo-light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schluters/nlw-move-on/HEAD/public/move-on-logo-light.png -------------------------------------------------------------------------------- /vercel.json: -------------------------------------------------------------------------------- 1 | { 2 | "rewrites": [ 3 | { "source": "/api/levelup.png", "destination": "/api/levelup" } 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /public/images/touch/apple-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schluters/nlw-move-on/HEAD/public/images/touch/apple-icon.png -------------------------------------------------------------------------------- /babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: ["next/babel"], 3 | plugins: [["styled-components", { "ssr": true }]] 4 | } 5 | -------------------------------------------------------------------------------- /public/images/touch/favicon-16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schluters/nlw-move-on/HEAD/public/images/touch/favicon-16x16.png -------------------------------------------------------------------------------- /public/images/touch/favicon-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schluters/nlw-move-on/HEAD/public/images/touch/favicon-32x32.png -------------------------------------------------------------------------------- /public/images/touch/favicon-96x96.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schluters/nlw-move-on/HEAD/public/images/touch/favicon-96x96.png -------------------------------------------------------------------------------- /public/images/touch/ms-icon-70x70.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schluters/nlw-move-on/HEAD/public/images/touch/ms-icon-70x70.png -------------------------------------------------------------------------------- /next-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | /// 4 | -------------------------------------------------------------------------------- /public/images/touch/apple-icon-57x57.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schluters/nlw-move-on/HEAD/public/images/touch/apple-icon-57x57.png -------------------------------------------------------------------------------- /public/images/touch/apple-icon-60x60.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schluters/nlw-move-on/HEAD/public/images/touch/apple-icon-60x60.png -------------------------------------------------------------------------------- /public/images/touch/apple-icon-72x72.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schluters/nlw-move-on/HEAD/public/images/touch/apple-icon-72x72.png -------------------------------------------------------------------------------- /public/images/touch/apple-icon-76x76.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schluters/nlw-move-on/HEAD/public/images/touch/apple-icon-76x76.png -------------------------------------------------------------------------------- /public/images/touch/apple-touch-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schluters/nlw-move-on/HEAD/public/images/touch/apple-touch-icon.png -------------------------------------------------------------------------------- /public/images/touch/ms-icon-150x150.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schluters/nlw-move-on/HEAD/public/images/touch/ms-icon-150x150.png -------------------------------------------------------------------------------- /public/images/touch/ms-icon-310x310.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schluters/nlw-move-on/HEAD/public/images/touch/ms-icon-310x310.png -------------------------------------------------------------------------------- /public/images/touch/android-icon-36x36.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schluters/nlw-move-on/HEAD/public/images/touch/android-icon-36x36.png -------------------------------------------------------------------------------- /public/images/touch/android-icon-48x48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schluters/nlw-move-on/HEAD/public/images/touch/android-icon-48x48.png -------------------------------------------------------------------------------- /public/images/touch/android-icon-72x72.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schluters/nlw-move-on/HEAD/public/images/touch/android-icon-72x72.png -------------------------------------------------------------------------------- /public/images/touch/android-icon-96x96.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schluters/nlw-move-on/HEAD/public/images/touch/android-icon-96x96.png -------------------------------------------------------------------------------- /public/images/touch/apple-icon-114x114.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schluters/nlw-move-on/HEAD/public/images/touch/apple-icon-114x114.png -------------------------------------------------------------------------------- /public/images/touch/apple-icon-120x120.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schluters/nlw-move-on/HEAD/public/images/touch/apple-icon-120x120.png -------------------------------------------------------------------------------- /public/images/touch/apple-icon-144x144.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schluters/nlw-move-on/HEAD/public/images/touch/apple-icon-144x144.png -------------------------------------------------------------------------------- /public/images/touch/apple-icon-152x152.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schluters/nlw-move-on/HEAD/public/images/touch/apple-icon-152x152.png -------------------------------------------------------------------------------- /public/images/touch/apple-icon-180x180.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schluters/nlw-move-on/HEAD/public/images/touch/apple-icon-180x180.png -------------------------------------------------------------------------------- /public/images/touch/android-icon-144x144.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schluters/nlw-move-on/HEAD/public/images/touch/android-icon-144x144.png -------------------------------------------------------------------------------- /public/images/touch/android-icon-192x192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schluters/nlw-move-on/HEAD/public/images/touch/android-icon-192x192.png -------------------------------------------------------------------------------- /public/images/touch/apple-icon-precomposed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schluters/nlw-move-on/HEAD/public/images/touch/apple-icon-precomposed.png -------------------------------------------------------------------------------- /public/icons/play-arrow.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /prettier.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | printWidth: 120, 3 | semi: false, 4 | singleQuote: true, 5 | arrowParens: 'avoid', 6 | trailingComma: 'none', 7 | endOfline: 'auto' 8 | } 9 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = space 5 | indent_size = 2 6 | charset = utf-8 7 | trim_trailing_whitespace = true 8 | insert_final_newline = true 9 | end_of_line = lf 10 | 11 | [*.md] 12 | trim_trailing_whitespace = false 13 | -------------------------------------------------------------------------------- /public/icons/close.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/styles/themes/dark.ts: -------------------------------------------------------------------------------- 1 | export default { 2 | title: 'dark', 3 | colors: { 4 | shape: '#202024', 5 | background: '#121214', 6 | grayLine: '#29292e', 7 | text: '#a8a8b3', 8 | textHighlight: '#B3B9FF', 9 | title: '#e1e1e6', 10 | invertWhite: 'brightness(10%) contrast(100%)', 11 | invertBlack: 'brightness(0) invert(1)', 12 | overlay: 'rgba(0, 0, 0, 0.75)' 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/styles/themes/light.ts: -------------------------------------------------------------------------------- 1 | export default { 2 | title: 'light', 3 | colors: { 4 | shape: '#fff', 5 | background: '#f2f3f5', 6 | grayLine: '#DCDDE0', 7 | text: '#666666', 8 | textHighlight: '#B3B9FF', 9 | title: '#2E384D', 10 | invertWhite: 'brightness(0) invert(1)', 11 | invertBlack: 'brightness(10%) contrast(100%)', 12 | overlay: 'rgba(254, 254, 254, 0.75)' 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/styles/styled.d.ts: -------------------------------------------------------------------------------- 1 | import 'styled-components' 2 | declare module 'styled-components' { 3 | export interface DefaultTheme { 4 | title: string 5 | colors: { 6 | shape: string 7 | background: string 8 | grayLine: string 9 | text: string 10 | textHighlight: string 11 | title: string 12 | invertWhite: string 13 | invertBlack: string 14 | overlay: string 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /public/icons/check-circle.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/styles/components/CompletedChallenges.module.css: -------------------------------------------------------------------------------- 1 | .completedChallengesContainer { 2 | display: flex; 3 | align-items: center; 4 | justify-content: space-between; 5 | margin: 3.5rem 0; 6 | padding-bottom: 1rem; 7 | border-bottom: 2px solid var(--gray-line); 8 | font-weight: 500; 9 | } 10 | 11 | .completedChallengesContainer span:first-child { 12 | font-size: 1.25rem; 13 | } 14 | 15 | .completedChallengesContainer span:last-child { 16 | font-size: 1.5rem; 17 | } 18 | -------------------------------------------------------------------------------- /public/browserconfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | #e1e1e6 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /public/icons/medal.svg: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /public/icons/moveon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/components/CompletedChallenges.tsx: -------------------------------------------------------------------------------- 1 | import React, { useContext } from 'react' 2 | import { ChallengesContext } from '../contexts/ChallengesContext' 3 | import styles from '../styles/components/CompletedChallenges.module.css' 4 | 5 | export function CompletedChallenges(): JSX.Element { 6 | const { challengesCompleted } = useContext(ChallengesContext) 7 | return ( 8 |
9 | Desafios completos 10 | {challengesCompleted} 11 |
12 | ) 13 | } 14 | -------------------------------------------------------------------------------- /public/bg-moveon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.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 | # next.js 12 | /.next/ 13 | /out/ 14 | 15 | # production 16 | /build 17 | 18 | # misc 19 | .DS_Store 20 | *.pem 21 | 22 | # debug 23 | npm-debug.log* 24 | yarn-debug.log* 25 | yarn-error.log* 26 | 27 | # local env files 28 | .env 29 | .env.development 30 | .env.staging 31 | .env.prestaging 32 | .env.production 33 | 34 | # vercel 35 | .vercel 36 | 37 | # next-pwa 38 | **/public/workbox-*.js 39 | **/public/sw.js 40 | -------------------------------------------------------------------------------- /src/styles/pages/Home.module.css: -------------------------------------------------------------------------------- 1 | .container { 2 | height: 100vh; 3 | max-width: 992px; 4 | margin: 0 auto; 5 | padding: 2.5rem 2rem; 6 | display: flex; 7 | flex-direction: column; 8 | } 9 | 10 | .container section { 11 | flex: 1; 12 | display: grid; 13 | grid-template-columns: 1fr 1fr; 14 | gap: 6.25rem; 15 | align-content: center; 16 | } 17 | 18 | @media(max-width: 767px) { 19 | .container { 20 | margin-top: 7rem; 21 | } 22 | .container section { 23 | flex: 1; 24 | display: grid; 25 | grid-template-columns: 1fr; 26 | gap: 2rem; 27 | align-content: center; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /next.config.js: -------------------------------------------------------------------------------- 1 | const withPWA = require('next-pwa') 2 | const withImages = require('next-images') 3 | const withBundleAnalyzer = require('@next/bundle-analyzer') 4 | 5 | module.exports = { 6 | target: 'serverless', 7 | webpack: function (config) { 8 | config.module.rules.push({test: /\.md$/, use: 'raw-loader'}) 9 | 10 | return config 11 | } 12 | } 13 | module.exports = withImages({ 14 | esModule: true, 15 | }) 16 | module.exports = withPWA({ 17 | pwa: { 18 | disable: process.env.NODE_ENV === 'development', 19 | dest: 'public' 20 | } 21 | }) 22 | module.exports = (phase, defaultConfig) => { 23 | return withBundleAnalyzer(defaultConfig) 24 | } 25 | -------------------------------------------------------------------------------- /src/utils/usePersistedState.ts: -------------------------------------------------------------------------------- 1 | import { useState, useEffect, Dispatch, SetStateAction } from 'react' 2 | 3 | type Response = [T, Dispatch>] 4 | 5 | function usePersistedState(key: string, initialState: T): Response { 6 | const [value, setValue] = useState(initialState) 7 | 8 | useEffect(() => { 9 | const stickyValue = window.localStorage.getItem(key) 10 | if (stickyValue !== null) { 11 | setValue(JSON.parse(stickyValue)) 12 | } 13 | }, [key]) 14 | 15 | useEffect(() => { 16 | window.localStorage.setItem(key, JSON.stringify(value)) 17 | }, [key, value]) 18 | 19 | return [value, setValue] 20 | } 21 | export default usePersistedState 22 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "lib": ["dom", "dom.iterable", "esnext"], 5 | "allowJs": true, 6 | "skipLibCheck": true, 7 | "strict": false, 8 | "forceConsistentCasingInFileNames": true, 9 | "noEmit": true, 10 | "esModuleInterop": true, 11 | "module": "esnext", 12 | "moduleResolution": "node", 13 | "resolveJsonModule": true, 14 | "isolatedModules": true, 15 | "jsx": "preserve" 16 | }, 17 | "include": [ 18 | "next-env.d.ts", 19 | "**/*.ts", 20 | "**/*.tsx", 21 | "src/pages/api/users/[id].js" 22 | ], 23 | "exclude": ["node_modules"], 24 | "files": ["src/styles/styled.d.ts"] 25 | } 26 | -------------------------------------------------------------------------------- /public/icons/twitter.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/pages/api/_lib/chromium.ts: -------------------------------------------------------------------------------- 1 | import puppeteer, { Page } from 'puppeteer-core' 2 | import { getOptions } from './chromeOptions' 3 | 4 | let _page: Page | null 5 | 6 | async function getPage(isDev: boolean): Promise { 7 | if (_page) { 8 | return _page 9 | } 10 | const options = await getOptions(isDev) 11 | const browser = await puppeteer.launch(options) 12 | _page = await browser.newPage() 13 | return _page 14 | } 15 | 16 | export async function getScreenshot(html: string, isDev: boolean): Promise { 17 | const page = await getPage(isDev) 18 | await page.setViewport({ width: 1200, height: 630 }) 19 | await page.setContent(html) 20 | await page.evaluateHandle('document.fonts.ready') 21 | const file = await page.screenshot({ type: 'png' }) 22 | 23 | return file 24 | } 25 | -------------------------------------------------------------------------------- /src/components/ExperienceBar.tsx: -------------------------------------------------------------------------------- 1 | import React, { useContext } from 'react' 2 | import { ChallengesContext } from '../contexts/ChallengesContext' 3 | import styles from '../styles/components/ExperienceBar.module.css' 4 | 5 | export function ExperienceBar(): JSX.Element { 6 | const { currentExperience, experienceToNextLevel } = useContext(ChallengesContext) 7 | const percentToNextLevel = Math.round(currentExperience * 100) / experienceToNextLevel 8 | return ( 9 |
10 | 0 xp 11 |
12 |
13 | 14 | {currentExperience} xp 15 | 16 |
17 |
18 | {experienceToNextLevel} xp 19 |
20 | ) 21 | } 22 | -------------------------------------------------------------------------------- /src/utils/firebase.ts: -------------------------------------------------------------------------------- 1 | import * as firebase from 'firebase/app' 2 | import 'firebase/auth' 3 | import 'firebase/database' 4 | 5 | const config = { 6 | apiKey: process.env.NEXT_PUBLIC_FIREBASE_API_KEY, 7 | authDomain: `${process.env.NEXT_PUBLIC_FIREBASE_PROJECT_ID}.firebaseapp.com`, 8 | projectId: process.env.NEXT_PUBLIC_FIREBASE_PROJECT_ID, 9 | databaseURL: `https://${process.env.NEXT_PUBLIC_FIREBASE_PROJECT_ID}-default-rtdb.firebaseio.com/`, 10 | storageBucket: `${process.env.NEXT_PUBLIC_FIREBASE_PROJECT_ID}.appspot.com`, 11 | messagingSenderId: '1058018246800', 12 | appId: '1:1058018246800:web:968086df2853ba69a71815', 13 | measurementId: 'G-F4HVQEFCLD' 14 | } 15 | 16 | export function loadFirebase() { 17 | function initFirebase(): void { 18 | if (!firebase.default.apps.length) { 19 | firebase.default.initializeApp(config) 20 | } 21 | } 22 | initFirebase() 23 | return firebase.default.database() 24 | } 25 | -------------------------------------------------------------------------------- /src/components/Profile.tsx: -------------------------------------------------------------------------------- 1 | import React, { useContext } from 'react' 2 | import { signOut } from 'next-auth/client' 3 | 4 | import { ChallengesContext } from '../contexts/ChallengesContext' 5 | import styles from '../styles/components/Profile.module.css' 6 | 7 | export function Profile(props): JSX.Element { 8 | const { level } = useContext(ChallengesContext) 9 | return ( 10 |
11 |
12 | {props.data.user.name} 13 |
14 | {props.data.user.name} 15 |

16 | Level 17 | Level {level} 18 |

19 |
20 |
21 | 24 |
25 | ) 26 | } 27 | -------------------------------------------------------------------------------- /src/pages/api/auth/[...nextauth].js: -------------------------------------------------------------------------------- 1 | import NextAuth from 'next-auth' 2 | import Providers from 'next-auth/providers' 3 | 4 | // eslint-disable-next-line @typescript-eslint/explicit-function-return-type 5 | export default (req, res) => 6 | NextAuth(req, res, { 7 | // Configure one or more authentication providers 8 | providers: [ 9 | Providers.GitHub({ 10 | clientId: process.env.GITHUB_ID, 11 | clientSecret: process.env.GITHUB_SECRET 12 | }), 13 | Providers.Google({ 14 | clientId: process.env.GOOGLE_CLIENT_ID, 15 | clientSecret: process.env.GOOGLE_CLIENT_SECRET 16 | }), 17 | Providers.Facebook({ 18 | clientId: process.env.FACEBOOK_CLIENT_ID, 19 | clientSecret: process.env.FACEBOOK_CLIENT_SECRET 20 | }) 21 | ], 22 | debug: process.env.NODE_ENV === 'development', 23 | secret: process.env.AUTH_SECRET, 24 | jwt: { 25 | secret: process.env.JWT_SECRET 26 | } 27 | }) 28 | -------------------------------------------------------------------------------- /src/pages/api/_lib/chromeOptions.ts: -------------------------------------------------------------------------------- 1 | import chrome from 'chrome-aws-lambda' 2 | 3 | const chromeExecPaths = { 4 | win32: 'C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe', 5 | linux: '/usr/bin/google-chrome', 6 | darwin: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome' 7 | } 8 | 9 | const exePath = chromeExecPaths[process.platform] 10 | interface Options { 11 | args: string[] 12 | executablePath: string 13 | headless: boolean 14 | } 15 | 16 | export async function getOptions(isDev: boolean): Promise { 17 | let options: Options 18 | if (isDev) { 19 | options = { 20 | args: [], 21 | executablePath: exePath, 22 | headless: true 23 | } 24 | } else { 25 | options = { 26 | args: [...chrome.args, '--no-sandbox', '--disable-setuid-sandbox'], 27 | executablePath: await chrome.executablePath, 28 | headless: false 29 | // headless: chrome.headless 30 | } 31 | } 32 | return options 33 | } 34 | -------------------------------------------------------------------------------- /src/styles/pages/Leaderboard.module.css: -------------------------------------------------------------------------------- 1 | .container { 2 | width: 100%; 3 | height: 100vh; 4 | max-width: 992px; 5 | margin: 0 auto; 6 | padding: 2.5rem 2rem; 7 | display: flex; 8 | flex-direction: column; 9 | } 10 | 11 | .container .headoard { 12 | display: flex; 13 | flex-direction: row; 14 | align-items: center; 15 | justify-content: flex-start; 16 | margin-bottom: 2.75rem; 17 | } 18 | 19 | .headoard h2 { 20 | color: var(--title); 21 | font-size: 2.8rem; 22 | transition: color 0.3s ease 0s; 23 | } 24 | 25 | .leaderboard header { 26 | width: 100%; 27 | display: grid; 28 | grid-template-columns: 2fr 6fr 2fr 2fr; 29 | margin-bottom: 1.25rem; 30 | } 31 | 32 | .leaderboard .title { 33 | font-size: 1rem; 34 | font-weight: 600; 35 | color: var(--text); 36 | text-transform: uppercase; 37 | } 38 | 39 | @media(max-width: 767px) { 40 | .container { 41 | margin-top: 7rem; 42 | } 43 | .leaderboard .title { 44 | font-size: 0.75rem; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/styles/components/Profile.module.css: -------------------------------------------------------------------------------- 1 | .profileWrapper { 2 | display: flex; 3 | flex-direction: row; 4 | align-items: center; 5 | justify-content: space-between; 6 | } 7 | .profileContainer { 8 | display: flex; 9 | align-items: center; 10 | } 11 | 12 | .profileContainer > img { 13 | width: 5.5rem; 14 | height: 5.5rem; 15 | border-radius: 50%; 16 | } 17 | 18 | .profileContainer div { 19 | margin-left: 1.5rem; 20 | } 21 | 22 | .profileContainer div strong { 23 | font-size: 1.5rem; 24 | font-weight: 600; 25 | color: var(--title); 26 | } 27 | 28 | .profileContainer div p { 29 | font-size: 1rem; 30 | margin-top: 0.5rem; 31 | } 32 | 33 | .profileContainer div p img { 34 | margin-right: 0.5rem; 35 | } 36 | 37 | .profileWrapper button { 38 | background:none; 39 | font-size: 0; 40 | transition: linear 0.2s; 41 | border: 2px solid var(--gray-line); 42 | border-radius: 50px; 43 | } 44 | .profileWrapper button:hover { 45 | transform:scale(1.3); 46 | box-shadow: 0 0 1rem 0.5rem rgba(0, 0, 0, 0.2); 47 | } 48 | -------------------------------------------------------------------------------- /src/styles/components/ExperienceBar.module.css: -------------------------------------------------------------------------------- 1 | .experienceBar { 2 | display: flex; 3 | align-items: center; 4 | margin-bottom: 2rem; 5 | } 6 | 7 | .experienceBar span { 8 | font-size: 1rem; 9 | } 10 | 11 | .experienceBar > div { 12 | flex: 1; 13 | height: 4px; 14 | border-radius: 4px; 15 | background: var(--gray-line); 16 | margin: 0 1.5rem; 17 | position: relative; 18 | } 19 | 20 | .experienceBar > div > div { 21 | height: 4px; 22 | border-radius: 4px; 23 | background: var(--green); 24 | } 25 | 26 | span.currentExperience { 27 | position: absolute; 28 | top: 17px; 29 | transform: translateX(-50%); 30 | text-align: center; 31 | background: var(--green); 32 | color: var(--title); 33 | padding: 0.5rem; 34 | border-radius: 5px; 35 | white-space: nowrap; 36 | } 37 | 38 | span.currentExperience::after { 39 | display: block; 40 | content: " "; 41 | position: absolute; 42 | top: -6px; 43 | left: 50%; 44 | margin-left: -6px; 45 | width: 0; 46 | height: 0; 47 | border-left: 6px solid transparent; 48 | border-bottom: 6px solid var(--green); 49 | border-right: 6px solid transparent; 50 | border-top: 0 solid transparent; 51 | } 52 | -------------------------------------------------------------------------------- /public/move-on-logo.svg: -------------------------------------------------------------------------------- 1 | move-on-logo -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "browser": true, 4 | "es2021": true, 5 | "node": true, 6 | "jest": true 7 | }, 8 | "extends": [ 9 | "plugin:react/recommended", 10 | "standard", 11 | "plugin:@typescript-eslint/recommended", 12 | "plugin:prettier/recommended", 13 | "prettier" 14 | ], 15 | "parser": "@typescript-eslint/parser", 16 | "parserOptions": { 17 | "ecmaFeatures": { 18 | "jsx": true 19 | }, 20 | "ecmaVersion": 12, 21 | "sourceType": "module" 22 | }, 23 | "plugins": ["react", "@typescript-eslint", "prettier"], 24 | "rules": { 25 | "react/jsx-filename-extension": [1, { "extensions": [".tsx"] }], 26 | "import/prefer-default-export": "off", 27 | "prettier/prettier": "error", 28 | "space-before-function-paren": "off", 29 | "react/prop-types": "off", 30 | "@typescript-eslint/explicit-module-boundary-types": "off", 31 | "@typescript-eslint/explicit-function-return-type": [ 32 | "error", 33 | { 34 | "allowExpressions": true 35 | } 36 | ], 37 | "no-use-before-define": ["off"], 38 | "import/no-duplicates": ["off"] 39 | }, 40 | "settings": { 41 | "import/resolver": { 42 | "typescript": {} 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/styles/components/LevelUpModal.module.css: -------------------------------------------------------------------------------- 1 | .overlay { 2 | background: rgba(254, 254, 254, 0.75); 3 | position: fixed; 4 | top: 0; 5 | bottom: 0; 6 | left: 0; 7 | right: 0; 8 | display: flex; 9 | align-items: center; 10 | justify-content: center; 11 | z-index: 2; 12 | } 13 | .container { 14 | background: var(--shape); 15 | width: 100%; 16 | max-width: 26.25rem; 17 | padding: 2rem 3rem; 18 | border-radius: 5px; 19 | box-shadow: 0 0 50px rgba(0, 0, 0, 0.05); 20 | text-align: center; 21 | position: relative; 22 | } 23 | 24 | .container header { 25 | font-size: 8.75rem; 26 | font-weight: 600; 27 | color: var(--blue); 28 | background: url('/icons/levelup.svg') no-repeat center; 29 | background-size: contain; 30 | } 31 | 32 | .container strong { 33 | font-size: 2.25rem; 34 | color: var(--title); 35 | } 36 | 37 | .container p { 38 | font-size: 1.25rem; 39 | color: var(--text); 40 | margin-top: 0.25rem; 41 | } 42 | 43 | .close { 44 | position: absolute; 45 | right: 0.5rem; 46 | top: 0.5rem; 47 | background:none; 48 | border:0; 49 | font-size: 0; 50 | } 51 | 52 | .socialShare { 53 | margin-top: 2rem; 54 | display: flex; 55 | flex-direction: row; 56 | align-items: center; 57 | justify-content: space-around; 58 | } 59 | -------------------------------------------------------------------------------- /public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Move.On", 3 | "short_name": "MoveOn", 4 | "theme_color": "#121214", 5 | "background_color": "#121214", 6 | "start_url": "/", 7 | "display": "fullscreen", 8 | "orientation": "portrait", 9 | "icons": [ 10 | { 11 | "src": "/images/touch/android-icon-36x36.png", 12 | "sizes": "36x36", 13 | "type": "image\/png", 14 | "density": "0.75" 15 | }, 16 | { 17 | "src": "/images/touch/android-icon-48x48.png", 18 | "sizes": "48x48", 19 | "type": "image\/png", 20 | "density": "1.0" 21 | }, 22 | { 23 | "src": "/images/touch/android-icon-72x72.png", 24 | "sizes": "72x72", 25 | "type": "image\/png", 26 | "density": "1.5" 27 | }, 28 | { 29 | "src": "/images/touch/android-icon-96x96.png", 30 | "sizes": "96x96", 31 | "type": "image\/png", 32 | "density": "2.0" 33 | }, 34 | { 35 | "src": "/images/touch/android-icon-144x144.png", 36 | "sizes": "144x144", 37 | "type": "image\/png", 38 | "density": "3.0" 39 | }, 40 | { 41 | "src": "/images/touch/android-icon-192x192.png", 42 | "sizes": "192x192", 43 | "type": "image\/png", 44 | "density": "4.0" 45 | }], 46 | "related_applications": [{ 47 | "platform": "web", 48 | "url": "https://nlw-move-on.vercel.app" 49 | }] 50 | } 51 | -------------------------------------------------------------------------------- /src/pages/api/levelup.ts: -------------------------------------------------------------------------------- 1 | import { NextApiRequest, NextApiResponse } from 'next' 2 | import { getScreenshot } from './_lib/chromium' 3 | import { getHtml } from './_lib/levelupTemplate' 4 | 5 | const isDev = !process.env.AWS_REGION 6 | const isHtmlDebug = process.env.OG_HTML_DEBUG === '1' 7 | 8 | export default async (req: NextApiRequest, res: NextApiResponse): Promise => { 9 | try { 10 | const query = req.query 11 | 12 | const level = Number(query.level) 13 | const challenges = Number(query.challenges) 14 | const totalxp = Number(query.totalxp) 15 | const theme = query.theme === 'dark' ? 'dark' : 'light' 16 | 17 | if (!level) { 18 | throw new Error('Level is required') 19 | } 20 | 21 | const html = getHtml({ level, challenges, totalxp, theme }) 22 | 23 | if (isHtmlDebug) { 24 | res.setHeader('Content-Type', 'text/html') 25 | res.end(html) 26 | return 27 | } 28 | 29 | const file = await getScreenshot(html, isDev) 30 | 31 | res.statusCode = 200 32 | res.setHeader('Content-Type', `image/png`) 33 | res.setHeader('Cache-Control', 'public, immutable, no-transform, s-maxage=31536000, max-age=31536000') 34 | res.end(file) 35 | } catch (err) { 36 | console.error(err) 37 | res.statusCode = 500 38 | res.setHeader('Content-Type', 'text/html') 39 | res.end('

Internal Error

Sorry, there was a problem

') 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /public/icons/github.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /src/pages/_app.tsx: -------------------------------------------------------------------------------- 1 | /* eslint-disable @typescript-eslint/no-explicit-any */ 2 | import React, { ReactNode } from 'react' 3 | import { AppInitialProps, AppProps } from 'next/app' 4 | import Head from 'next/head' 5 | import { ThemeProvider, DefaultTheme } from 'styled-components' 6 | import usePersistedState from '../utils/usePersistedState' 7 | import light from '../styles/themes/light' 8 | import dark from '../styles/themes/dark' 9 | import GlobalStyle from '../styles/global' 10 | import { Provider } from 'next-auth/client' 11 | 12 | function MyApp({ 13 | Component, 14 | ...pageProps 15 | }: AppInitialProps & { Component: any; session: any; toggleTheme: void }): JSX.Element { 16 | const [theme, setTheme] = usePersistedState('theme', light) 17 | const toggleTheme = (): void => setTheme(theme.title === 'light' ? dark : light) 18 | const sessionApp = pageProps.session 19 | return ( 20 | 27 | 28 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | ) 39 | } 40 | 41 | export default MyApp 42 | -------------------------------------------------------------------------------- /src/_layouts/LevelUpLayout.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import Head from 'next/head' 3 | import levelup from '../pages/api/levelup' 4 | 5 | interface LevelUpLayoutProps { 6 | title: string 7 | description: string 8 | levelUpUrl: string 9 | content: string 10 | } 11 | 12 | export default function LevelUpLayout(props: LevelUpLayoutProps): JSX.Element { 13 | return ( 14 |
15 | 16 | {props.title} 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 |
31 |

{props.title}

32 | {props.title} 33 |
34 |
35 |
36 | ) 37 | } 38 | -------------------------------------------------------------------------------- /public/icons/bkp/eye.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /public/icons/body.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /public/logo-nlw.svg: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /public/icons/level.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /src/components/ChallengeBox.tsx: -------------------------------------------------------------------------------- 1 | import React, { useContext } from 'react' 2 | import styles from '../styles/components/ChallengeBox.module.css' 3 | import { ChallengesContext } from '../contexts/ChallengesContext' 4 | import { CountdownContext } from '../contexts/CountdownContext' 5 | 6 | export function ChallangeBox(): JSX.Element { 7 | const { activeChallenge, resetChallenge, completeChallenge } = useContext(ChallengesContext) 8 | const { resetCountdown } = useContext(CountdownContext) 9 | 10 | function handleChallengeSucceeded(): void { 11 | completeChallenge() 12 | resetCountdown() 13 | } 14 | 15 | function handleChallengeFailed(): void { 16 | resetChallenge() 17 | resetCountdown() 18 | } 19 | 20 | return ( 21 |
22 | {activeChallenge ? ( 23 |
24 |
Ganhe {activeChallenge.amount} xp
25 |
26 | 27 | Novo Desafio 28 |

{activeChallenge.description}

29 |
30 |
31 | 34 | 37 |
38 |
39 | ) : ( 40 |
41 | Inicie um ciclo para receber desafios a serem completados 42 |

43 | Level Up 44 | Complete-os e ganhe experiência e avance de leve. 45 |

46 |
47 | )} 48 |
49 | ) 50 | } 51 | -------------------------------------------------------------------------------- /src/components/Sidebar.tsx: -------------------------------------------------------------------------------- 1 | import React, { useContext } from 'react' 2 | import { useRouter } from 'next/router' 3 | import Link from 'next/link' 4 | import Switch from 'react-switch' 5 | import { ThemeContext } from 'styled-components' 6 | import { BiHomeAlt, BiMedal, BiSun, BiMoon } from 'react-icons/bi' 7 | import styles from '../styles/components/Sidebar.module.css' 8 | 9 | export function Sidebar({ toggleTheme }): JSX.Element { 10 | const router = useRouter() 11 | const { colors, title } = useContext(ThemeContext) 12 | return ( 13 | 54 | ) 55 | } 56 | -------------------------------------------------------------------------------- /public/icons/eye.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/components/Countdown.tsx: -------------------------------------------------------------------------------- 1 | import React, { useContext } from 'react' 2 | import { CountdownContext } from '../contexts/CountdownContext' 3 | import styles from '../styles/components/Countdown.module.css' 4 | 5 | export function Countdown(): JSX.Element { 6 | const { minutes, seconds, isActive, hasFinished, startCountdown, resetCountdown, percentToClose } = useContext( 7 | CountdownContext 8 | ) 9 | 10 | const [minuteL, minuteR] = String(minutes).padStart(2, '0').split('') 11 | const [secondL, secondR] = String(seconds).padStart(2, '0').split('') 12 | 13 | return ( 14 | <> 15 |
16 |
17 | {minuteL} 18 | {minuteR} 19 |
20 | : 21 |
22 | {secondL} 23 | {secondR} 24 |
25 |
26 | {hasFinished ? ( 27 | 31 | ) : ( 32 | <> 33 | {isActive ? ( 34 | 43 | ) : ( 44 | 52 | )} 53 | 54 | )} 55 | 56 | ) 57 | } 58 | -------------------------------------------------------------------------------- /src/pages/login.tsx: -------------------------------------------------------------------------------- 1 | import React, { useEffect } from 'react' 2 | import { AppProps } from 'next/dist/next-server/lib/router/router' 3 | import Head from 'next/head' 4 | import { useRouter } from 'next/router' 5 | import { signIn, useSession } from 'next-auth/client' 6 | import styles from '../styles/pages/Login.module.css' 7 | import { IoLogoFacebook, IoLogoGithub, IoLogoGoogle } from 'react-icons/io' 8 | 9 | const Login: React.FC = ({ ...pageProps }) => { 10 | const userSession = pageProps.pageProps.session 11 | const [loading] = useSession() 12 | const router = useRouter() 13 | useEffect(() => { 14 | if (!(pageProps.session || loading)) { 15 | router.push('/login') 16 | } else { 17 | router.push('/') 18 | } 19 | }, [userSession, loading]) 20 | 21 | return ( 22 |
23 | 24 | Sign in | Move.On 25 | 26 |
27 | MoveOn 28 | Bem-vindo 29 |

Conecte-se para começar seus desafios

30 |
31 | 34 | 37 | 40 |
41 | 42 | O MoveOn é uma aplicação com base na técnica Pomodoro, destinada a desenvolvedores para 43 | auxiliar no cuidado da sua saúde e postura. 44 | 45 |
46 |
47 | ) 48 | } 49 | export default Login 50 | -------------------------------------------------------------------------------- /public/icons/drinking.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 7 | 9 | 10 | 11 | 12 | 14 | 15 | 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 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "move-on", 3 | "version": "0.1.0", 4 | "private": true, 5 | "scripts": { 6 | "dev": "next dev", 7 | "build": "next build", 8 | "start": "next start", 9 | "test": "jest" 10 | }, 11 | "dependencies": { 12 | "@next/bundle-analyzer": "^10.0.8", 13 | "chrome-aws-lambda": "^6.0.*", 14 | "firebase": "^8.2.9", 15 | "firebase-admin": "^9.5.0", 16 | "js-cookie": "^2.2.1", 17 | "next": "^10.0.7", 18 | "next-auth": "^3.6.0", 19 | "next-firebase-auth": "^0.13.0-alpha.0", 20 | "next-images": "^1.7.0", 21 | "next-pwa": "^5.0.5", 22 | "puppeteer-core": "^6.0.*", 23 | "react": "17.0.1", 24 | "react-device-detect": "^1.15.0", 25 | "react-dom": "17.0.1", 26 | "react-hot-toast": "^1.0.2", 27 | "react-icons": "^4.2.0", 28 | "react-share": "^4.4.0", 29 | "react-switch": "^6.0.0", 30 | "styled-components": "^5.2.1" 31 | }, 32 | "devDependencies": { 33 | "@babel/core": "^7.0.0", 34 | "@firebase/app-types": "^0.6.1", 35 | "@firebase/firestore-types": "^2.1.0", 36 | "@types/jest": "^26.0.20", 37 | "@types/js-cookie": "^2.2.6", 38 | "@types/next-auth": "^3.1.24", 39 | "@types/node": "^14.14.31", 40 | "@types/puppeteer": "^5.4.3", 41 | "@types/react": "^17.0.2", 42 | "@types/react-dom": "^17.0.1", 43 | "@types/styled-components": "^5.1.7", 44 | "@types/styled-components-react-native": "^5.1.1", 45 | "@typescript-eslint/eslint-plugin": "^4.16.1", 46 | "@typescript-eslint/parser": "^4.16.1", 47 | "@vercel/node": "^1.9.0", 48 | "csstype": "^2.6.2", 49 | "eslint": "^7.21.0", 50 | "eslint-config-prettier": "^8.1.0", 51 | "eslint-config-standard": "^16.0.2", 52 | "eslint-plugin-import": "^2.22.1", 53 | "eslint-plugin-node": "^11.1.0", 54 | "eslint-plugin-prettier": "^3.3.1", 55 | "eslint-plugin-promise": "^4.3.1", 56 | "eslint-plugin-react": "^7.22.0", 57 | "jest": "^26.6.3", 58 | "prettier": "^2.2.1", 59 | "prettier-eslint": "^12.0.0", 60 | "react-is": "^17.0.1", 61 | "typescript": "^4.1.5", 62 | "webpack": "^4.4.0" 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/components/Score.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import styles from '../styles/components/Score.module.css' 3 | 4 | export function Score(props): JSX.Element { 5 | const usersSorted = [] 6 | const list = props.profiles 7 | Object.keys(list) 8 | .sort((a, b) => { 9 | return list[b].totalxp - list[a].totalxp 10 | }) 11 | .map(key => { 12 | usersSorted.push( 13 | Object.assign( 14 | { 15 | key: list[key] 16 | }, 17 | list[key] 18 | ) 19 | ) 20 | return usersSorted 21 | }) 22 | return ( 23 |
    24 | {usersSorted.map( 25 | (user: any, idx: number): JSX.Element => { 26 | if (user.totalxp > 0) { 27 | return ( 28 |
  • 29 |
    30 | {idx + 1} 31 |
    32 |
    33 | 34 | {user.user.name} 35 |
    36 | {user.user.name} 37 | 38 | Level 39 | Level {user.level} 40 | 41 |
    42 |
    43 | 44 | 45 |

    46 | {user.challenges} completado{user.challenges > 1 && 's'} 47 |

    48 |
    49 | 50 |

    51 | {user.totalxp} xp 52 |

    53 |
    54 |
    55 |
    56 |
  • 57 | ) 58 | } 59 | } 60 | )} 61 |
62 | ) 63 | } 64 | -------------------------------------------------------------------------------- /src/contexts/CountdownContext.tsx: -------------------------------------------------------------------------------- 1 | import React, { createContext, useContext, useEffect, useState } from 'react' 2 | import { ChallengesContext } from './ChallengesContext' 3 | interface CountdownContextData { 4 | minutes: number 5 | seconds: number 6 | hasFinished: boolean 7 | isActive: boolean 8 | startCountdown: () => void 9 | resetCountdown: () => void 10 | percentToClose: number 11 | } 12 | 13 | export const CountdownContext = createContext({} as CountdownContextData) 14 | 15 | let countdownTimeout: NodeJS.Timeout 16 | export function CountdownProvider({ children, stealing }): JSX.Element { 17 | let timer = 25 18 | stealing && (timer = 0.05) 19 | const { startNewChallange, resetChallenge } = useContext(ChallengesContext) 20 | const challengeTime = timer * 60 21 | const [time, setTime] = useState(challengeTime) 22 | const [isActive, setIsActive] = useState(false) 23 | const [hasFinished, setHasFinished] = useState(false) 24 | const [percentToClose, setPercentToClose] = useState(0) 25 | 26 | const minutes = Math.floor(time / 60) 27 | const seconds = time % 60 28 | 29 | function startCountdown(): void { 30 | setIsActive(true) 31 | setTime(challengeTime) 32 | setPercentToClose(100 - (time / challengeTime) * 100) 33 | } 34 | 35 | function resetCountdown(): void { 36 | clearTimeout(countdownTimeout) 37 | resetChallenge() 38 | setPercentToClose(0) 39 | setIsActive(false) 40 | setHasFinished(false) 41 | setTime(challengeTime) 42 | } 43 | 44 | useEffect(() => { 45 | if (isActive && time > 0) { 46 | const countdownTimeout = window.setTimeout(() => { 47 | setTime(time - 1) 48 | setPercentToClose(100 - (time / challengeTime) * 100) 49 | }, 1000) 50 | } else if (isActive && time === 0) { 51 | startNewChallange() 52 | setHasFinished(true) 53 | setIsActive(false) 54 | } 55 | }, [isActive, time]) 56 | 57 | return ( 58 | 69 | {children} 70 | 71 | ) 72 | } 73 | -------------------------------------------------------------------------------- /src/styles/components/Sidebar.module.css: -------------------------------------------------------------------------------- 1 | .sidebarContainer { 2 | background-image: linear-gradient(var(--shape),var(--background)); 3 | height: 100vh; 4 | width: 5rem; 5 | min-width: 5rem; 6 | display: flex; 7 | align-items: stretch; 8 | justify-content: space-between; 9 | flex-direction: column; 10 | position: fixed; 11 | top: 0; 12 | left: 0; 13 | z-index: 1; 14 | } 15 | 16 | .header { 17 | display: flex; 18 | flex-direction: column; 19 | align-items: center; 20 | justify-content: center; 21 | } 22 | 23 | .header img { 24 | display: block; 25 | width: 100%; 26 | margin-top: 1rem; 27 | max-width: 4.5rem; 28 | cursor: alias; 29 | } 30 | .nav ul { 31 | list-style: none; 32 | } 33 | .nav ul li { 34 | text-align: center; 35 | position: relative; 36 | padding: .5rem 0; 37 | margin: .5rem 0; 38 | } 39 | 40 | .nav li.active:before { 41 | content: " "; 42 | display: block; 43 | background: var(--green); 44 | width: 4px; 45 | position: absolute; 46 | top: 0; 47 | bottom: 0; 48 | left: 0; 49 | border-radius: 0 5px 5px 0; 50 | } 51 | 52 | .nav li a svg { 53 | fill: var(--text); 54 | width: 2.25rem; 55 | height: 2.25rem; 56 | } 57 | 58 | .nav li.active a svg { 59 | fill: var(--green); 60 | } 61 | 62 | .footer { 63 | display: flex; 64 | flex-direction: column; 65 | align-items: center; 66 | justify-content: center; 67 | padding: 2rem 0; 68 | font-size: 1rem; 69 | line-height: 2; 70 | color: var(--text) 71 | } 72 | 73 | 74 | @media(max-width: 767px) { 75 | .sidebarContainer { 76 | background-image: none; 77 | background-color: var(--shape); 78 | height: 5rem; 79 | width: 100vw; 80 | min-width: 100%; 81 | flex-direction: row; 82 | } 83 | 84 | .header img { 85 | margin-top: -10px; 86 | } 87 | 88 | .nav ul { 89 | display: flex; 90 | align-items: center; 91 | justify-content: center; 92 | flex-direction: row; 93 | height: 100%; 94 | } 95 | 96 | .nav ul li { 97 | padding: 0 .5rem; 98 | margin: 0 .5rem; 99 | height: 100%; 100 | display: flex; 101 | align-items: center; 102 | } 103 | 104 | .nav li.active:before { 105 | width: 100%; 106 | height: 4px; 107 | border-radius: 0 0 5px 5px; 108 | } 109 | 110 | .footer { 111 | padding: 0 2rem; 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /src/styles/components/Countdown.module.css: -------------------------------------------------------------------------------- 1 | .countdownContainer { 2 | display: flex; 3 | align-items: center; 4 | font-family: Rajdhani; 5 | font-weight: 600; 6 | color: var(--title); 7 | } 8 | 9 | .countdownContainer > div { 10 | flex: 1; 11 | display: flex; 12 | align-items: center; 13 | justify-content: space-evenly; 14 | background: var(--shape); 15 | box-shadow: 0 0 60px rgba(0, 0, 0, 0.05); 16 | border-radius: 5px; 17 | font-size: 8.5rem; 18 | text-align: center; 19 | } 20 | 21 | .countdownContainer > div span { 22 | flex: 1; 23 | } 24 | 25 | .countdownContainer > div span:first-child { 26 | border-right: 1px solid var(--gray-line); 27 | } 28 | 29 | .countdownContainer > div span:last-child { 30 | border-left: 1px solid var(--gray-line); 31 | } 32 | 33 | .countdownContainer > span { 34 | font-size: 6.25rem; 35 | margin: 0 0.5rem; 36 | } 37 | 38 | .countdownButton { 39 | width: 100%; 40 | height: 5rem; 41 | margin-top: 2rem; 42 | display: flex; 43 | align-items: center; 44 | justify-content: center; 45 | border: 0; 46 | border-radius: 5px; 47 | background: var(--blue); 48 | color: var(--shape); 49 | font-size: 1.25rem; 50 | font-weight: 600; 51 | transition: background-color 0.2s; 52 | position: relative; 53 | overflow: hidden; 54 | } 55 | 56 | .countdownButton img { 57 | margin-left: 0.5rem; 58 | } 59 | 60 | .countdownButton:not(:disabled):hover { 61 | background: var(--blue-dark); 62 | } 63 | 64 | .countdownButton:disabled { 65 | background: var(--shape); 66 | color: var(--text); 67 | cursor: not-allowed; 68 | border-bottom: 4px solid var(--green); 69 | } 70 | 71 | 72 | .countdownButtonActive { 73 | background: var(--shape); 74 | color: var(--title); 75 | box-shadow: inset 0 -4px 0px var(--gray-line); 76 | } 77 | 78 | .countdownButtonActive span { 79 | position: absolute; 80 | left: 0; 81 | bottom: 0; 82 | height: 4px; 83 | background: var(--red); 84 | border-radius: 1px; 85 | transition: width 1s linear; 86 | } 87 | 88 | .countdownButtonActive:not(:disabled):hover { 89 | background: var(--red); 90 | color: var(--shape); 91 | } 92 | 93 | .countdownButtonActive:not(:disabled):hover img { 94 | filter: var(--invert-white); 95 | } 96 | 97 | .countdownButtonStart:not(:disabled) img { 98 | filter: var(--invert-white); 99 | } 100 | -------------------------------------------------------------------------------- /public/icons/level-up.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/pages/api/_lib/levelupTemplate.ts: -------------------------------------------------------------------------------- 1 | export type Theme = 'light' | 'dark' 2 | interface GetHtmlProps { 3 | level: number 4 | challenges: number 5 | totalxp: number 6 | theme?: Theme 7 | } 8 | 9 | export function getHtml({ level, challenges, totalxp, theme = 'light' }: GetHtmlProps): string { 10 | return ` 11 | 12 | 13 | 14 | 18 | 22 | 23 | 24 |
25 |
26 |
27 |

${level}

28 |

Avancei para o próximo level

29 |
30 |
31 |
32 |
33 |

Desafios

34 |

35 | ${challenges} completado${challenges > 1 && 's'} 36 |

37 |
38 |
39 |

Experiência

40 |

41 | ${totalxp} xp 42 |

43 |
44 | 45 |
46 |
47 | 48 | ` 49 | } 50 | -------------------------------------------------------------------------------- /src/styles/pages/Login.module.css: -------------------------------------------------------------------------------- 1 | .wrapper { 2 | height: 100vh; 3 | width: 100vw; 4 | /* background-color: #202024; */ 5 | /* background: linear-gradient(45deg, #202024 0%, #1e1e1e 50%, #202024 100%); */ 6 | background: #202024 url('/bg-moveon.svg') no-repeat center left; 7 | background-size: cover; 8 | overflow: hidden; 9 | display: flex; 10 | flex-direction: column; 11 | align-items: center; 12 | } 13 | 14 | .container { 15 | height: 100vh; 16 | width: 100%; 17 | max-width: 30rem; 18 | padding: 2.5rem 2rem; 19 | display: flex; 20 | flex: 1; 21 | flex-direction: column; 22 | align-items: flex-start; 23 | justify-content: center; 24 | text-align: left; 25 | margin-left: 25%; 26 | } 27 | .container .logo { 28 | margin-bottom: 2rem; 29 | } 30 | 31 | .container strong { 32 | font-size: 3rem; 33 | font-weight: 600; 34 | line-height: 1.4; 35 | margin-bottom: 0.5rem; 36 | color: #fff; 37 | } 38 | 39 | .container p { 40 | font-size: 1rem; 41 | font-weight: 400; 42 | line-height: 1.4; 43 | margin-bottom: 2rem; 44 | color: #f2f3f5; 45 | } 46 | 47 | .container small { 48 | font-size: 0.75rem; 49 | font-weight: 400; 50 | line-height: 1.4; 51 | margin-bottom: 2rem; 52 | color: #f2f3f5; 53 | } 54 | .container small strong { 55 | font-size: 0.75rem; 56 | } 57 | 58 | .buttons { 59 | display: flex; 60 | flex-direction: column; 61 | align-items: center; 62 | justify-content: center; 63 | width: 100%; 64 | margin-bottom: 2rem; 65 | } 66 | 67 | .container button { 68 | width: 100%; 69 | height: 3rem; 70 | padding: 1rem; 71 | margin-bottom: 1rem; 72 | display: flex; 73 | align-items: center; 74 | justify-content: center; 75 | border-radius: 5px; 76 | font-size: 1.25rem; 77 | font-weight: 400; 78 | transition: filter 0.2s; 79 | position: relative; 80 | overflow: hidden; 81 | color: #fff; 82 | border: none; 83 | box-shadow: 0 0 1rem 0.25rem rgba(0, 0, 0, 0.2); 84 | } 85 | .container button:last-child { 86 | margin-bottom: 0; 87 | } 88 | 89 | .container button:not(:disabled):hover { 90 | filter: brightness(0.9); 91 | } 92 | 93 | .container button svg { 94 | margin-right: 0.5rem; 95 | } 96 | 97 | button.git { 98 | background: #24292e; 99 | } 100 | button.gg { 101 | background: #DB4437; 102 | } 103 | button.fb { 104 | background: #4267B2; 105 | } 106 | 107 | @media(max-width: 767px) { 108 | .container { 109 | margin-left: 0; 110 | } 111 | .container button { 112 | font-size: 1rem; 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /src/styles/components/ChallengeBox.module.css: -------------------------------------------------------------------------------- 1 | .challangeBoxConainer { 2 | height: 100%; 3 | min-height: 320px; 4 | background: var(--shape); 5 | border-radius: 5px; 6 | box-shadow: 0 0 50px rgba(0, 0, 0, 0.05); 7 | padding: 1.5rem 3.2rem; 8 | display: flex; 9 | flex-direction: column; 10 | align-items: center; 11 | justify-content: center; 12 | text-align: center; 13 | } 14 | 15 | .challangeNotActive { 16 | display: flex; 17 | flex-direction: column; 18 | align-items: center; 19 | } 20 | 21 | .challangeNotActive strong { 22 | font-size: 1.5rem; 23 | font-weight: 500; 24 | line-height: 1.4; 25 | } 26 | 27 | .challangeNotActive p { 28 | width: 90%; 29 | display: flex; 30 | flex-direction: row; 31 | align-items: center; 32 | line-height: 1.4; 33 | justify-content: space-around; 34 | margin-top: 3rem; 35 | text-align: left; 36 | } 37 | 38 | .challangeNotActive img { 39 | margin-right: 0.5rem; 40 | width: 2rem; 41 | } 42 | 43 | .challangeActive { 44 | height: 100%; 45 | display: flex; 46 | flex-direction: column; 47 | } 48 | 49 | .challangeActive header { 50 | color: var(--blue); 51 | font-weight: 600; 52 | font-size: 1.25rem; 53 | padding: 0 2rem 1.5rem; 54 | border-bottom: 1px solid var(--gray-line); 55 | } 56 | 57 | .challangeActive main { 58 | flex: 1; 59 | display: flex; 60 | flex-direction: column; 61 | align-items: center; 62 | justify-content: center; 63 | } 64 | 65 | .challangeActive main strong { 66 | font-size: 2rem; 67 | font-weight: 600; 68 | color: var(--title); 69 | margin: 1.5rem 0 1rem; 70 | } 71 | 72 | .challangeActive main p { 73 | line-height: 1.5; 74 | } 75 | .challangeActive main img { 76 | width: 100%; 77 | max-width: 10rem; 78 | } 79 | 80 | .challangeActive footer { 81 | display: grid; 82 | grid-template-columns: 1fr 1fr; 83 | gap: 1rem; 84 | margin-top: 0.75rem; 85 | } 86 | 87 | .challangeActive footer button { 88 | height: 3rem; 89 | display:flex; 90 | align-items: center; 91 | justify-content: center; 92 | border: 0; 93 | border-radius: 5px; 94 | color: var(--shape); 95 | font-size: 1rem; 96 | font-weight: 600; 97 | transition: filter 0.2s; 98 | padding: 0 0.75rem; 99 | } 100 | 101 | .challangeActive footer button:hover { 102 | filter: brightness(0.9); 103 | } 104 | 105 | .challangeActive footer button.challangeFailedButton { 106 | background: var(--red); 107 | } 108 | .challangeActive footer button.ChallengesucceededButton { 109 | background: var(--green) 110 | } 111 | 112 | 113 | @media(max-width: 767px) { 114 | .challangeBoxConainer { 115 | height: auto; 116 | margin-bottom: 2rem; 117 | } 118 | .challangeActive main img { 119 | margin-top: 1.5rem; 120 | } 121 | .challangeActive footer { 122 | margin-top: 1.5rem; 123 | } 124 | } 125 | -------------------------------------------------------------------------------- /src/styles/global.ts: -------------------------------------------------------------------------------- 1 | import { createGlobalStyle } from 'styled-components' 2 | 3 | export default createGlobalStyle` 4 | :root { 5 | --shape: ${props => props.theme.colors.shape}; 6 | --background: ${props => props.theme.colors.background}; 7 | --gray-line: ${props => props.theme.colors.grayLine}; 8 | --text: ${props => props.theme.colors.text}; 9 | --text-highlight: ${props => props.theme.colors.textHighlight}; 10 | --title: ${props => props.theme.colors.title}; 11 | --red: #E83F5B; 12 | --green: #4CD62B; 13 | --blue: #5965E0; 14 | --blue-dark: #4953B8; 15 | --blue-twitter: #2AA9E0; 16 | --invert-white: ${props => props.theme.colors.invertWhite}; 17 | --invert-black: ${props => props.theme.colors.invertBlack}; 18 | --overlay: ${props => props.theme.colors.overlay}; 19 | } 20 | 21 | * { 22 | margin: 0; 23 | padding: 0; 24 | box-sizing: border-box; 25 | } 26 | 27 | html { 28 | font-size: 16px; 29 | } 30 | 31 | body { 32 | background: var(--background); 33 | color: var(--text); 34 | } 35 | 36 | body, input, textarea, button { 37 | font: 400 1rem "Montserrat", sans-serif; 38 | } 39 | 40 | button { 41 | cursor: pointer; 42 | } 43 | 44 | a { 45 | color: inherit; 46 | text-decoration: none; 47 | } 48 | 49 | .wrapper { 50 | height: 100vh; 51 | display: flex; 52 | align-items: center; 53 | margin-left: 5rem; 54 | } 55 | 56 | @media(max-width: 1080px) { 57 | html { 58 | font-size: 93.75%; 59 | } 60 | } 61 | 62 | @media(max-width: 767px) { 63 | html { 64 | font-size: 87.5%; 65 | } 66 | .wrapper { 67 | margin-left: 0; 68 | } 69 | } 70 | 71 | @media(min-width: 768px) { 72 | :focus { 73 | outline: 2px dotted var(--green); 74 | filter: brightness(1.2) saturate(2); 75 | } 76 | } 77 | 78 | .loading { 79 | height: 100vh; 80 | width: 100%; 81 | display: flex; 82 | align-items: center; 83 | justify-content: center; 84 | align-content: center; 85 | background: rgba(0, 0, 0, 0.975); 86 | position: fixed; 87 | top: 0; 88 | left: 0; 89 | z-index: 3; 90 | } 91 | 92 | ::-webkit-scrollbar { 93 | width: 0.625rem; 94 | height: 0.625rem; 95 | } 96 | 97 | ::-webkit-scrollbar-button:start:decrement, 98 | ::-webkit-scrollbar-button:end:increment { 99 | display: none; 100 | } 101 | 102 | ::-webkit-scrollbar-track-piece { 103 | /* background-color: #3b3b3b; */ 104 | background-color: var(--gray-line); 105 | -webkit-border-radius: 6px; 106 | } 107 | 108 | ::-webkit-scrollbar-thumb:vertical { 109 | background-color: var(--green); 110 | -webkit-border-radius: 6px; 111 | } 112 | 113 | .c-loader { 114 | animation: pulsate 1s infinite; 115 | border: 6px solid var(--gray-line); 116 | border-radius: 50%; 117 | border-top-color: var(--green); 118 | height: 3.75rem; 119 | width: 3.75rem; 120 | } 121 | 122 | @keyframes pulsate { 123 | 0% {transform: scale(1.0, 1.0) rotate(0deg); opacity: 0.5;} 124 | 50% {transform: scale(1.2, 1.2) rotate(1turn); opacity: 1;} 125 | 100% {transform: scale(1.0, 1.0) rotate(360deg); opacity: 0.5;} 126 | } 127 | 128 | ` 129 | -------------------------------------------------------------------------------- /src/styles/components/Score.module.css: -------------------------------------------------------------------------------- 1 | .container { 2 | width: 100%; 3 | display: flex; 4 | flex-direction: column; 5 | align-items: flex-start; 6 | justify-content: flex-start; 7 | list-style: none; 8 | margin-bottom: 2rem; 9 | } 10 | 11 | .user, .topUser { 12 | width: 100%; 13 | display: grid; 14 | grid-template-columns: 1fr 11fr; 15 | margin-bottom: 1rem; 16 | } 17 | 18 | .position { 19 | padding: 1rem; 20 | display: flex; 21 | flex-direction: column; 22 | align-items: center; 23 | justify-content: center; 24 | margin-right: 4px; 25 | background: var(--shape); 26 | border-top-left-radius: 0.75rem; 27 | border-bottom-left-radius: 0.75rem; 28 | position: relative; 29 | overflow: hidden; 30 | } 31 | 32 | .topUser .position::before { 33 | display: block; 34 | content: " "; 35 | background: url(/icons/medal.svg) no-repeat center center; 36 | background-size: contain; 37 | width: 2.25rem; 38 | height: 2.25rem; 39 | position: absolute; 40 | top: -0.25rem; 41 | bottom: 0; 42 | right: 0.25rem; 43 | } 44 | 45 | .position strong { 46 | font-size: 1.5rem; 47 | color: var(--title); 48 | } 49 | 50 | .info { 51 | padding: 1rem; 52 | display: grid; 53 | grid-template-columns: 7fr 4fr; 54 | background: var(--shape); 55 | border-top-right-radius: 0.75rem; 56 | border-bottom-right-radius: 0.75rem; 57 | } 58 | 59 | .profile { 60 | display: flex; 61 | flex-direction: row; 62 | align-items: center; 63 | justify-content: flex-start; 64 | } 65 | 66 | .avatar { 67 | width: 4rem; 68 | height: 4rem; 69 | margin-right: 1rem; 70 | border-radius: 50%; 71 | } 72 | 73 | .profile strong { 74 | font-size: 1.5rem; 75 | font-weight: 600; 76 | color: var(--title); 77 | } 78 | 79 | .profile div { 80 | display: flex; 81 | flex-direction: column; 82 | align-items: flex-start; 83 | justify-content: center; 84 | } 85 | 86 | .profile span { 87 | font-size: 1rem; 88 | margin-top: 0.5rem; 89 | } 90 | 91 | .profile span img { 92 | margin-right: 0.5rem; 93 | } 94 | 95 | .score { 96 | display: grid; 97 | grid-template-columns: 1.5fr 1fr; 98 | } 99 | .score span { 100 | display: flex; 101 | flex-direction: column; 102 | align-items: flex-start; 103 | justify-content: center; 104 | } 105 | .score p { 106 | font-size: 1rem; 107 | line-height: 1.4; 108 | font-weight: 600; 109 | color: var(--text); 110 | } 111 | .score strong { 112 | color: var(--blue-dark); 113 | } 114 | 115 | @media(max-width: 767px) { 116 | .user, .topUser { 117 | grid-template-columns: 1.5fr 10.5fr; 118 | } 119 | 120 | .position { 121 | padding: 1rem 1.5rem; 122 | } 123 | 124 | .avatar { 125 | width: 2rem; 126 | height: 2rem; 127 | } 128 | 129 | .profile strong { 130 | font-size: 1rem; 131 | } 132 | .score span { 133 | align-items: center; 134 | text-align: center; 135 | } 136 | .score p { 137 | font-size: 0.75rem; 138 | } 139 | .score strong { 140 | font-size: 1.25rem; 141 | display: block; 142 | } 143 | 144 | .topUser .position::before { 145 | width: 2rem; 146 | height: 2rem; 147 | right: 0; 148 | } 149 | 150 | } 151 | -------------------------------------------------------------------------------- /public/icons/toilet.svg: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /public/logo-full.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /src/pages/leaderboard.tsx: -------------------------------------------------------------------------------- 1 | import React, { useEffect, useState } from 'react' 2 | import Head from 'next/head' 3 | import { GetServerSideProps } from 'next' 4 | import { useSession } from 'next-auth/client' 5 | 6 | import { useRouter } from 'next/router' 7 | import { loadFirebase } from '../utils/firebase' 8 | import styles from '../styles/pages/Leaderboard.module.css' 9 | import { Sidebar } from '../components/Sidebar' 10 | import { Score } from '../components/Score' 11 | import { AppProps } from 'next/dist/next-server/lib/router/router' 12 | 13 | const Leaderboard: React.FC = ({ toggleTheme, ...rest }) => { 14 | const router = useRouter() 15 | const [session, loading] = useSession() 16 | const [isRefreshing, setIsRefreshing] = useState(false) 17 | const [initialUsers] = useState(rest.pageProps.profiles) 18 | 19 | const refreshData = (): void => { 20 | router.replace(router.asPath) 21 | setIsRefreshing(true) 22 | } 23 | useEffect(() => { 24 | setIsRefreshing(false) 25 | }, [initialUsers]) 26 | 27 | useEffect(() => { 28 | if (!(session || loading)) { 29 | router.push('/login') 30 | } else { 31 | router.push('/leaderboard') 32 | } 33 | }, [session, loading]) 34 | 35 | if (session) { 36 | return ( 37 | <> 38 | 39 | Leaderboard | Move.On 40 | 41 |
42 | 43 |
44 |
45 |

Leaderboard

46 |
47 |
48 |
49 |

Posição

50 |

Usuário

51 |

Desafios

52 |

Experiência

53 |
54 | 55 |
56 |
57 |
58 | 59 | ) 60 | } 61 | return ( 62 |
63 | 64 |
65 | ) 66 | } 67 | export default Leaderboard 68 | 69 | export const getServerSideProps: GetServerSideProps = async () => { 70 | const firebase = loadFirebase() 71 | const result = await new Promise((resolve, reject) => { 72 | firebase 73 | .ref('profiles') 74 | .get() 75 | .then(snapshot => { 76 | const data = [] 77 | snapshot.forEach(user => { 78 | data.push( 79 | Object.assign( 80 | { 81 | key: user.key 82 | }, 83 | user.val() 84 | ) 85 | ) 86 | }) 87 | // eslint-disable-next-line array-callback-return 88 | data.filter((user, idx): void => { 89 | const nextUser = data[idx + 1] 90 | if (nextUser) { 91 | if (user.user.email === nextUser.user.email) { 92 | loadFirebase().ref('profiles').child(nextUser.key).remove() 93 | } 94 | } 95 | }) 96 | resolve(data) 97 | }) 98 | .catch(error => { 99 | reject(console.log(error.stack)) 100 | }) 101 | }) 102 | return { 103 | props: { profiles: result } 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /public/icons/body-2.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/pages/_document.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import Document, { Html, Head, Main, NextScript, DocumentInitialProps, DocumentContext } from 'next/document' 3 | 4 | const APP_NAME = 'Move.On' 5 | const APP_DESCRIPTION = 6 | 'O MoveOn é uma aplicação com base na técnica Pomodoro, destinada a desenvolvedores para auxiliar no cuidado da sua saúde e postura.' 7 | export default class MyDocument extends Document { 8 | static async getInitialProps(ctx: DocumentContext): Promise { 9 | return await Document.getInitialProps(ctx) 10 | } 11 | 12 | render(): JSX.Element { 13 | return ( 14 | 15 | 16 | 17 | 18 | 19 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 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 |
69 | 70 | 71 | 72 | ) 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/components/LevelUpModal.tsx: -------------------------------------------------------------------------------- 1 | import React, { useContext } from 'react' 2 | import Head from 'next/head' 3 | import { ChallengesContext } from '../contexts/ChallengesContext' 4 | import styles from '../styles/components/LevelUpModal.module.css' 5 | import { isMobile } from 'react-device-detect' 6 | import { FacebookIcon, LinkedinIcon, TwitterIcon, WhatsappIcon } from 'react-share' 7 | import { FacebookShareButton, LinkedinShareButton, TwitterShareButton, WhatsappShareButton } from 'react-share' 8 | 9 | export function LevelUpModal(): JSX.Element { 10 | const { level, challengesCompleted, totalExperience, closeLevelUpModal } = useContext(ChallengesContext) 11 | return ( 12 | <> 13 | 14 | Siga em frente com os seus desafios / Move On with your challenges | Move.On 15 | 16 | 17 | 18 | 19 | 23 | 24 | 25 | 26 | 27 | 31 | 32 |
33 |
34 |
{level}
35 | Parabéns 36 |

Voce alcançou um novo level!

37 | 40 |
41 | 46 | 47 | 48 | 54 | 55 | 56 | 60 | 61 | 62 | {isMobile && ( 63 | 67 | 68 | 69 | )} 70 |
71 |
72 |
73 | 74 | ) 75 | } 76 | -------------------------------------------------------------------------------- /public/icons/levelup.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /challenges.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "type": "drinking", 4 | "description": "Levante-se e vá se hidratar! 🥃 Além de movimentar o corpo você mantenha-se hidratado", 5 | "amount": 150 6 | }, 7 | { 8 | "type": "toilet", 9 | "description": "Aproveite o intervalo para ir ao banheiro 💩, se estiver sem vontade, apenas de uma caminhada para esticar as pernas!", 10 | "amount": 20 11 | }, 12 | { 13 | "type": "body", 14 | "description": "Estique um de seus braços com a palma da mão virada para frente e puxe os dedos para cima por 10 segundos por mão.", 15 | "amount": 80 16 | }, 17 | { 18 | "type": "body", 19 | "description": "Estique seu braço contra o peito e puxe-o utilizando o outro braço por 10 segundos por braço.", 20 | "amount": 60 21 | }, 22 | { 23 | "type": "body", 24 | "description": "Puxe seu pescoço com a ajuda da mão para a direita e para a esquerda, permanecendo na posição por alguns segundos.", 25 | "amount": 70 26 | }, 27 | { 28 | "type": "body", 29 | "description": "Com as duas mãos na parte de trás da cabeça, leve-a para baixo, alongando a parte de trás da região.", 30 | "amount": 60 31 | }, 32 | { 33 | "type": "body", 34 | "description": "Cruze as pernas e desça com as mãos esticadas em direção ao chão. Repita o movimento com a outra perna na frente.", 35 | "amount": 100 36 | }, 37 | { 38 | "type": "body", 39 | "description": "Sentado, abra as pernas e tente encostar as palmas das mãos no chão, repita 3 vezes por 5 segundos.", 40 | "amount": 80 41 | }, 42 | { 43 | "type": "body", 44 | "description": "Puxe o joelho de encontro ao peito e segure, troque de perna após 10 segundos.", 45 | "amount": 50 46 | }, 47 | { 48 | "type": "body", 49 | "description": "Sentado, cruze uma perna e incline seu tronco à frente, troque de perna após 10 segundos.", 50 | "amount": 80 51 | }, 52 | { 53 | "type": "eye", 54 | "description": "Sentado, feche os olhos e cubra-os com as palmas da mão durante 2 minutos, depois abra normalmente.", 55 | "amount": 90 56 | }, 57 | { 58 | "type": "eye", 59 | "description": "Em algum ambiente aberto, olhe o mais longe que puder em quatro direções por 3s, mexa apenas os olhos. Repita 3 vezes.", 60 | "amount": 140 61 | }, 62 | { 63 | "type": "eye", 64 | "description": "Com o dedo, faça um número oito no ar, sempre acompanhando com o olhar e a cabeça parada. Faça isso por 30 segundos.", 65 | "amount": 80 66 | }, 67 | { 68 | "type": "eye", 69 | "description": "Usando os polegares, massage a área abaixo das sobrancelhas em movimentos circulares por 15 segundos.", 70 | "amount": 70 71 | }, 72 | { 73 | "type": "body", 74 | "description": "Em pé, gire a cintura o máximo que puder para a esquerda, segure por cinco segundos. Repita para a direita.", 75 | "amount": 90 76 | }, 77 | { 78 | "type": "body", 79 | "description": "Levante uma perna atrás, segurando pelo pé, e aguente por cinco segundos. Faça o mesmo com a outra perna e repita cinco vezes.", 80 | "amount": 90 81 | }, 82 | { 83 | "type": "body", 84 | "description": "Sentado, endireite a coluna, estique as pernas o máximo que conseguir e aguente dez segundos. Faça duas séries de dez.", 85 | "amount": 80 86 | }, 87 | { 88 | "type": "body", 89 | "description": "Estique as pernas à frente do seu corpo e alongue-se tentando pegar as pontas dos pés com as mãos.", 90 | "amount": 50 91 | }, 92 | { 93 | "type": "body", 94 | "description": "Estique seu braço direito em direção ao lado esquerdo o máximo que puder. Apoie a mão esquerda na dobra do seu cotovelo esquerdo, ajudando a alongá-lo. Sinta o alongamento por cerca de cinco segundos e, depois, faça o mesmo movimento com o outro braço. Tente repetir cinco vezes de cada lado.", 95 | "amount": 100 96 | }, 97 | { 98 | "type": "body", 99 | "description": "Coloque as mãos atrás da cabeça e leve os cotovelos lentamente para trás. Mantenha a posição por cerca de 20 segundos.", 100 | "amount": 50 101 | }, 102 | { 103 | "type": "body", 104 | "description": "Mexa cada um dos seus dedos com cuidado: estenda-os, flexione-os, abra-os e feche-os.", 105 | "amount": 50 106 | }, 107 | { 108 | "type": "body", 109 | "description": "Olhe para o chão e, segurando mais atrás da cabeça, tente encostar o queixo no peito, mais inclinado para o lado direito. Depois, repita para o outro lado.", 110 | "amount": 60 111 | }, 112 | { 113 | "type": "body", 114 | "description": "Estique os braços acima da cabeça, entrelaçando os dedos e se mantenha nesta posição por alguns segundos.", 115 | "amount": 60 116 | } 117 | ] 118 | -------------------------------------------------------------------------------- /src/contexts/ChallengesContext.tsx: -------------------------------------------------------------------------------- 1 | /* eslint-disable no-new */ 2 | import React, { createContext, useState, useEffect, useMemo } from 'react' 3 | import challenges from '../../challenges.json' 4 | import { LevelUpModal } from '../components/LevelUpModal' 5 | import toast from 'react-hot-toast' 6 | import { isMobile } from 'react-device-detect' 7 | interface Challenge { 8 | type: 'body' | 'eye' 9 | description: string 10 | amount: number 11 | } 12 | interface ChallengesContextData { 13 | level: number 14 | currentExperience: number 15 | experienceToNextLevel: number 16 | challengesCompleted: number 17 | totalExperience: number 18 | profileData: ProfilesProps 19 | activeChallenge: Challenge 20 | levelUp: () => void 21 | startNewChallange: () => void 22 | resetChallenge: () => void 23 | completeChallenge: () => void 24 | closeLevelUpModal: () => void 25 | } 26 | interface UserProps { 27 | name: string 28 | email: string 29 | image: string 30 | } 31 | interface ProfilesProps { 32 | user: UserProps 33 | level: number 34 | challenges: number 35 | currentxp: number 36 | totalxp: number 37 | } 38 | 39 | export const ChallengesContext = createContext({} as ChallengesContextData) 40 | 41 | export function ChallagesProvider({ children, ...rest }): JSX.Element { 42 | const [dataUser] = useState(rest.user) 43 | const [level, setLevel] = useState(dataUser.level) 44 | const [challengesCompleted, setChallengesCompleted] = useState(dataUser.challenges) 45 | const [currentExperience, setCurrentExperience] = useState(dataUser.currentxp) 46 | const [totalExperience, setTotalExperience] = useState(dataUser.totalxp) 47 | 48 | const [activeChallenge, setActiveChallenge] = useState(null) 49 | const [isLevelUpModalOpen, setIsLevelUpModalOpen] = useState(false) 50 | const experienceToNextLevel = Math.pow((level + 1) * 4, 2) 51 | const [profileData, setProfileData] = useState({ 52 | user: dataUser.user, 53 | level: level, 54 | challenges: challengesCompleted, 55 | currentxp: currentExperience, 56 | totalxp: totalExperience 57 | }) 58 | 59 | useEffect(() => { 60 | Notification.requestPermission() 61 | }, []) 62 | 63 | useEffect(() => { 64 | setProfileData({ 65 | user: dataUser.user, 66 | level: level, 67 | challenges: challengesCompleted, 68 | currentxp: currentExperience, 69 | totalxp: totalExperience 70 | }) 71 | }, [level, currentExperience, challengesCompleted, totalExperience]) 72 | 73 | useMemo(() => { 74 | rest.updateUser(profileData) 75 | }, [profileData]) 76 | 77 | function levelUp(): void { 78 | setLevel(level + 1) 79 | setIsLevelUpModalOpen(true) 80 | } 81 | 82 | function closeLevelUpModal(): void { 83 | setIsLevelUpModalOpen(false) 84 | } 85 | 86 | function startNewChallange(): void { 87 | const randomChallengeIndex = Math.floor(Math.random() * challenges.length) 88 | const challenge = challenges[randomChallengeIndex] 89 | setActiveChallenge(challenge) 90 | new Audio('/notification.mp3').play() 91 | const notify = (): string => 92 | toast(`Desafio disponível, valendo ${challenge.amount}xp!`, { 93 | duration: 5000, 94 | style: { 95 | borderRadius: '10px', 96 | background: 'var(--title)', 97 | color: 'var(--shape)' 98 | }, 99 | icon: '🥊', 100 | role: 'status', 101 | ariaLive: 'polite' 102 | }) 103 | notify() 104 | if ( 105 | 'showNotification' in ServiceWorkerRegistration.prototype && 106 | 'PushManager' in window && 107 | !(Notification.permission === 'denied') 108 | ) { 109 | if (isMobile) { 110 | navigator.serviceWorker.ready.then(registration => { 111 | registration.showNotification('Novo desafio disponível 🥊', { 112 | body: `Valendo ${challenge.amount}xp!`, 113 | icon: '/favicon.png', 114 | vibrate: [200, 100, 200, 100, 200, 100, 400] 115 | }) 116 | }) 117 | } else { 118 | new Notification('Novo desafio disponível 🥊', { 119 | body: `Valendo ${challenge.amount}xp!` 120 | }) 121 | } 122 | } 123 | } 124 | 125 | function resetChallenge(): void { 126 | setActiveChallenge(null) 127 | } 128 | 129 | function completeChallenge(): void { 130 | if (!activeChallenge) { 131 | return 132 | } 133 | const { amount } = activeChallenge 134 | let finalExperience = currentExperience + amount 135 | if (finalExperience >= experienceToNextLevel) { 136 | finalExperience = finalExperience - experienceToNextLevel 137 | levelUp() 138 | } 139 | setCurrentExperience(finalExperience) 140 | setActiveChallenge(null) 141 | setChallengesCompleted(challengesCompleted + 1) 142 | setTotalExperience(totalExperience + amount) 143 | rest.stealing && levelUp() 144 | } 145 | 146 | return ( 147 | 163 | {children} 164 | {isLevelUpModalOpen && } 165 | 166 | ) 167 | } 168 | -------------------------------------------------------------------------------- /public/icons/brain.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | Move.on 3 |

4 |

5 | 6 | License GPLv3 7 | 8 | 9 | Forks 10 | 11 | Stars 12 | 13 |

14 |

15 | 16 | ReactJS 17 | 18 | 19 | 20 | NextJS 21 | 22 | 23 |

24 | 25 | ## :bookmark_tabs: About 26 | 27 | **Move.On** is an application based on the [Pomodoro](https://pt.wikipedia.org/wiki/T%C3%A9cnica_pomodoro) technique, aimed at developers that assists in the care of your health and posture. 28 | 29 | System developed based on the knowledge acquired during a week of the **[<nlw/>#04](https://nextlevelweek.com/)** event by **[Rocketseat](https://rocketseat.com.br/)**, on the ReactJS trail taught by the famous “Fala Dev” [Diego Fernandes](https://github.com/diego3g). 30 | 31 |

32 |
33 | 34 | Figma 35 | 36 | 37 | Figma 38 | 39 |
40 | 41 | Layouts by Tiago Luchtenberg 42 | 43 |

44 | 45 | 46 | #### :computer: Preview application 47 | [![Deploy with Vercel](https://vercel.com/button)](https://nlw-move-on.vercel.app/) 48 | 49 | ## :ticket: Status 50 | :white_check_mark: DONE SUCCESSFULLY 51 | ```bash 52 | 22 fev - Rumo ao próximo nível - #rumoaoproximonivel 53 | 23 fev - Desvendando o Next.js - #jornadainfinita 54 | 24 fev - Contexto e componentes - #focopraticagrupo 55 | 25 fev - Storage, SSR & Lambda - #neverstoplearning 56 | 26 fev - Próximo nível com React - #missioncomplete 57 | 26 fev - Acelerando sua carreira - DONE 58 | ``` 59 | 60 | ## :tractor: Improvements 61 | - Added Sign In page 62 | - Added authentication with (Github, Google, Facebook) 63 | - Added Leaderboard page 64 | - Added Switch Theme Mode (Dark, Light) 65 | - Added Sidebar 66 | - Added PWA option in the application 67 | - Added Toast as notification 68 | - Added improvement in mobile notification 69 | - Added progress bar on the Abandon cycle button 70 | - Added share buttons (facebook, linkedin, twitter, whatsapp) 71 | - Added new challenges 72 | - Added new icons 73 | - Changed Color Scheme 74 | 75 | ## :electric_plug: Technology: 76 | 77 | - **[ReactJS](https://reactjs.org/)** 78 | - **[NextJS](https://nextjs.org/)** 79 | - **[TypeScript](https://www.typescriptlang.org/)** 80 | - **[Firebase](https://firebase.google.com/?hl=pt-br)** 81 | - **[Styled Components](https://styled-components.com/)** 82 | - **[NextAuth](https://next-auth.js.org/)** 83 | - **[Next PWA](https://github.com/shadowwalker/next-pwa)** 84 | - **[React Hot Toast](https://react-hot-toast.com/)** 85 | - **[React Icons](https://react-icons.github.io/react-icons/)** 86 | - **[React Share](https://github.com/nygardk/react-share)** 87 | - **[React Switch](https://github.com/markusenglund/react-switch)** 88 | - **[Puppeteer](https://pptr.dev/)** 89 | - **[Eslint](https://eslint.org/)** 90 | - **[Prettier](https://prettier.io/)** 91 | 92 | ## :rocket: How to run project 93 | Clone the project and access the folder 94 | 95 | ```bash 96 | $ git clone https://github.com/schluters/nlw-move-on.git && cd nlw-move-on 97 | ``` 98 | 99 | Follow the steps below 100 | ```bash 101 | # Install the dependencies 102 | $ yarn 103 | 104 | # Start the project 105 | $ yarn dev 106 | 107 | # The server will start at port:3000 - go to http://localhost:3000 108 | ``` 109 | 110 | ### :memo: Settings .ENV 111 | ```bash 112 | # BASE APP 113 | AUTH_SECRET="" 114 | JWT_SECRET="" 115 | NEXTAUTH_URL="http://localhost:3000" 116 | 117 | # FIREBASE 118 | NEXT_PUBLIC_FIREBASE_API_KEY="" 119 | NEXT_PUBLIC_FIREBASE_PROJECT_ID="" 120 | 121 | # GITHUB 122 | GITHUB_ID="" 123 | GITHUB_SECRET="" 124 | 125 | # GOOGLE 126 | GOOGLE_CLIENT_ID="" 127 | GOOGLE_CLIENT_SECRET="" 128 | 129 | # FACEBOOK 130 | FACEBOOK_CLIENT_ID="" 131 | FACEBOOK_CLIENT_SECRET="" 132 | ``` 133 | 134 | ## :confused: How to contribute to project 135 | 136 | - **Fork** the project; 137 | - Create a new branch with your changes: `git checkout -b my-feature` 138 | - Save your changes and create a proclamation message that you made: `git commit -m "feat: My new features"` 139 | - Submit your changes/feature: `git push origin my-feature` 140 | 141 | > In case of doubts: [Guide on how to contribute on GitHub](https://github.com/firstcontributions/first-contributions) 142 | 143 | 144 | ## :book: License 145 | 146 | Fully open and free code for studies and copies under license [GPLv3](/LICENSE). 147 | 148 | 149 | ## :mortar_board: Developed by 150 | 151 | Made with :green_heart: by **Herson Schluter** 152 | 153 |

154 | 155 | Rocketseat 156 | 157 | 158 | Github 159 | 160 | 161 | Linkedin 162 | 163 |

164 | -------------------------------------------------------------------------------- /src/pages/index.tsx: -------------------------------------------------------------------------------- 1 | import React, { useCallback, useEffect, useMemo, useState } from 'react' 2 | import Head from 'next/head' 3 | import { AppProps } from 'next/dist/next-server/lib/router/router' 4 | import { useRouter } from 'next/router' 5 | import { useSession, getSession } from 'next-auth/client' 6 | import { loadFirebase } from '../utils/firebase' 7 | import { toast, Toaster } from 'react-hot-toast' 8 | 9 | import styles from '../styles/pages/Home.module.css' 10 | 11 | import usePersistedState from '../utils/usePersistedState' 12 | import { CountdownProvider } from '../contexts/CountdownContext' 13 | import { ChallagesProvider } from '../contexts/ChallengesContext' 14 | 15 | import { Sidebar } from '../components/Sidebar' 16 | import { ExperienceBar } from '../components/ExperienceBar' 17 | import { Profile } from '../components/Profile' 18 | import { CompletedChallenges } from '../components/CompletedChallenges' 19 | import { Countdown } from '../components/Countdown' 20 | import { ChallangeBox } from '../components/ChallengeBox' 21 | interface UserProps { 22 | name: string 23 | email: string 24 | image: string 25 | } 26 | interface ProfilesProps { 27 | user: UserProps 28 | level: number 29 | challenges: number 30 | currentxp: number 31 | totalxp: number 32 | } 33 | const Page: React.FC = ({ ...pageProps }) => { 34 | const [stealing, setStealing] = usePersistedState('stealing', false) 35 | const [session, loading] = useSession() 36 | const router = useRouter() 37 | const profiles = pageProps.pageProps.profiles 38 | const userSession = pageProps.pageProps.session 39 | const notifyEmail = (): string => 40 | toast(`${userSession.user.name} precisamos do seu e-mail!, infelizmente seus dados não serão salvos`, { 41 | duration: 5000, 42 | style: { 43 | borderRadius: '10px', 44 | background: 'var(--title)', 45 | color: 'var(--shape)' 46 | }, 47 | icon: '☹', 48 | role: 'status', 49 | ariaLive: 'polite' 50 | }) 51 | const [isRefreshing, setIsRefreshing] = useState(false) 52 | 53 | const refreshData = (): void => { 54 | router.replace(router.asPath) 55 | setIsRefreshing(true) 56 | } 57 | 58 | useEffect(() => { 59 | setIsRefreshing(false) 60 | }, [profiles]) 61 | 62 | useEffect(() => { 63 | (pageProps.router.query.stealing === 'true') ? setStealing(true) : setStealing(false) 64 | if (!(session || loading)) { 65 | router.push('/login') 66 | } else { 67 | router.push('/') 68 | } 69 | }, [session, loading]) 70 | 71 | const loadUser = useMemo(() => { 72 | if (userSession) { 73 | !userSession.user.email && notifyEmail() 74 | const emptyUser = { 75 | user: userSession.user, 76 | level: 1, 77 | challenges: 0, 78 | currentxp: 0, 79 | totalxp: 0 80 | } 81 | loadFirebase() 82 | .ref('profiles') 83 | .get() 84 | .then(snapshot => { 85 | const users = [] 86 | snapshot.forEach(user => { 87 | users.push( 88 | Object.assign( 89 | { 90 | key: user.key 91 | }, 92 | user.val() 93 | ) 94 | ) 95 | }) 96 | const filterUser = users.filter((data: ProfilesProps) => data.user.email === userSession.user.email) 97 | filterUser.length > 1 && loadFirebase().ref('profiles').child(filterUser[1]).remove() 98 | }) 99 | 100 | profiles.length < 1 && loadFirebase().ref('profiles').push(emptyUser) 101 | const filterUser = profiles.filter((data: ProfilesProps) => data.user.email === userSession.user.email) 102 | filterUser.length > 1 && loadFirebase().ref('profiles').child(filterUser[1]).remove() 103 | const findUser = filterUser.find((data: ProfilesProps) => data.user.email === userSession.user.email) 104 | if (!findUser) { 105 | loadFirebase().ref('profiles').push(emptyUser) 106 | console.log('User created', userSession.user.email) 107 | return emptyUser 108 | } else { 109 | return findUser 110 | } 111 | } 112 | }, [userSession]) 113 | 114 | const updateProfile = useCallback(async xpData => { 115 | if (xpData.totalxp > 0) { 116 | xpData.user.email === loadUser.user.email && loadFirebase().ref('profiles').child(loadUser.key).update(xpData) 117 | } 118 | }, []) 119 | 120 | if (typeof window !== 'undefined' && loading) { 121 | return ( 122 |
123 | 124 |
125 | ) 126 | } 127 | if (session) { 128 | return ( 129 | 130 | 131 | Siga em frente com os seus desafios / Move On with your challenges | Move.On 132 | 133 |
134 | 135 | 136 |
137 | 138 | 139 |
140 |
141 | 142 | 143 | 144 |
145 |
146 | 147 |
148 |
149 |
150 |
151 |
152 |
153 | ) 154 | } 155 | return ( 156 |
157 | 158 |
159 | ) 160 | } 161 | export default Page 162 | 163 | export async function getServerSideProps(context): Promise { 164 | const session = await getSession(context) 165 | const firebase = loadFirebase() 166 | const profiles = await new Promise((resolve, reject) => { 167 | firebase 168 | .ref('profiles') 169 | .get() 170 | .then(snapshot => { 171 | const data = [] 172 | snapshot.forEach(user => { 173 | if (!user.val().user.email || user.val().user.email === '') { 174 | firebase.ref('profiles').child(user.key).remove() 175 | } 176 | data.push( 177 | Object.assign( 178 | { 179 | key: user.key 180 | }, 181 | user.val() 182 | ) 183 | ) 184 | }) 185 | // eslint-disable-next-line array-callback-return 186 | data.filter((user, idx): void => { 187 | const nextUser = data[idx + 1] 188 | if (nextUser) { 189 | if (user.user.email === nextUser.user.email) { 190 | loadFirebase().ref('profiles').child(nextUser.key).remove() 191 | } 192 | } 193 | }) 194 | resolve(data) 195 | }) 196 | .catch(error => { 197 | reject(console.log(error.stack)) 198 | }) 199 | }) 200 | 201 | return { 202 | props: { profiles, session } 203 | } 204 | } 205 | -------------------------------------------------------------------------------- /jest.config.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * For a detailed explanation regarding each configuration property and type check, visit: 3 | * https://jestjs.io/docs/en/configuration.html 4 | */ 5 | 6 | export default { 7 | // All imported modules in your tests should be mocked automatically 8 | // automock: false, 9 | 10 | // Stop running tests after `n` failures 11 | // bail: 0, 12 | 13 | // The directory where Jest should store its cached dependency information 14 | // cacheDirectory: "C:\\Users\\schlu\\AppData\\Local\\Temp\\jest", 15 | 16 | // Automatically clear mock calls and instances between every test 17 | clearMocks: true, 18 | 19 | // Indicates whether the coverage information should be collected while executing the test 20 | // collectCoverage: false, 21 | 22 | // An array of glob patterns indicating a set of files for which coverage information should be collected 23 | // collectCoverageFrom: undefined, 24 | 25 | // The directory where Jest should output its coverage files 26 | // coverageDirectory: undefined, 27 | 28 | // An array of regexp pattern strings used to skip coverage collection 29 | // coveragePathIgnorePatterns: [ 30 | // "\\\\node_modules\\\\" 31 | // ], 32 | 33 | // Indicates which provider should be used to instrument code for coverage 34 | // coverageProvider: "babel", 35 | 36 | // A list of reporter names that Jest uses when writing coverage reports 37 | // coverageReporters: [ 38 | // "json", 39 | // "text", 40 | // "lcov", 41 | // "clover" 42 | // ], 43 | 44 | // An object that configures minimum threshold enforcement for coverage results 45 | // coverageThreshold: undefined, 46 | 47 | // A path to a custom dependency extractor 48 | // dependencyExtractor: undefined, 49 | 50 | // Make calling deprecated APIs throw helpful error messages 51 | // errorOnDeprecated: false, 52 | 53 | // Force coverage collection from ignored files using an array of glob patterns 54 | // forceCoverageMatch: [], 55 | 56 | // A path to a module which exports an async function that is triggered once before all test suites 57 | // globalSetup: undefined, 58 | 59 | // A path to a module which exports an async function that is triggered once after all test suites 60 | // globalTeardown: undefined, 61 | 62 | // A set of global variables that need to be available in all test environments 63 | // globals: {}, 64 | 65 | // The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers. 66 | // maxWorkers: "50%", 67 | 68 | // An array of directory names to be searched recursively up from the requiring module's location 69 | // moduleDirectories: [ 70 | // "node_modules" 71 | // ], 72 | 73 | // An array of file extensions your modules use 74 | // moduleFileExtensions: [ 75 | // "js", 76 | // "json", 77 | // "jsx", 78 | // "ts", 79 | // "tsx", 80 | // "node" 81 | // ], 82 | 83 | // A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module 84 | // moduleNameMapper: {}, 85 | 86 | // An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader 87 | // modulePathIgnorePatterns: [], 88 | 89 | // Activates notifications for test results 90 | // notify: false, 91 | 92 | // An enum that specifies notification mode. Requires { notify: true } 93 | // notifyMode: "failure-change", 94 | 95 | // A preset that is used as a base for Jest's configuration 96 | // preset: undefined, 97 | 98 | // Run tests from one or more projects 99 | // projects: undefined, 100 | 101 | // Use this configuration option to add custom reporters to Jest 102 | // reporters: undefined, 103 | 104 | // Automatically reset mock state between every test 105 | // resetMocks: false, 106 | 107 | // Reset the module registry before running each individual test 108 | // resetModules: false, 109 | 110 | // A path to a custom resolver 111 | // resolver: undefined, 112 | 113 | // Automatically restore mock state between every test 114 | // restoreMocks: false, 115 | 116 | // The root directory that Jest should scan for tests and modules within 117 | // rootDir: undefined, 118 | 119 | // A list of paths to directories that Jest should use to search for files in 120 | // roots: [ 121 | // "" 122 | // ], 123 | 124 | // Allows you to use a custom runner instead of Jest's default test runner 125 | // runner: "jest-runner", 126 | 127 | // The paths to modules that run some code to configure or set up the testing environment before each test 128 | // setupFiles: [], 129 | 130 | // A list of paths to modules that run some code to configure or set up the testing framework before each test 131 | // setupFilesAfterEnv: [], 132 | 133 | // The number of seconds after which a test is considered as slow and reported as such in the results. 134 | // slowTestThreshold: 5, 135 | 136 | // A list of paths to snapshot serializer modules Jest should use for snapshot testing 137 | // snapshotSerializers: [], 138 | 139 | // The test environment that will be used for testing 140 | testEnvironment: 'node' 141 | 142 | // Options that will be passed to the testEnvironment 143 | // testEnvironmentOptions: {}, 144 | 145 | // Adds a location field to test results 146 | // testLocationInResults: false, 147 | 148 | // The glob patterns Jest uses to detect test files 149 | // testMatch: [ 150 | // "**/__tests__/**/*.[jt]s?(x)", 151 | // "**/?(*.)+(spec|test).[tj]s?(x)" 152 | // ], 153 | 154 | // An array of regexp pattern strings that are matched against all test paths, matched tests are skipped 155 | // testPathIgnorePatterns: [ 156 | // "\\\\node_modules\\\\" 157 | // ], 158 | 159 | // The regexp pattern or array of patterns that Jest uses to detect test files 160 | // testRegex: [], 161 | 162 | // This option allows the use of a custom results processor 163 | // testResultsProcessor: undefined, 164 | 165 | // This option allows use of a custom test runner 166 | // testRunner: "jasmine2", 167 | 168 | // This option sets the URL for the jsdom environment. It is reflected in properties such as location.href 169 | // testURL: "http://localhost", 170 | 171 | // Setting this value to "fake" allows the use of fake timers for functions such as "setTimeout" 172 | // timers: "real", 173 | 174 | // A map from regular expressions to paths to transformers 175 | // transform: undefined, 176 | 177 | // An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation 178 | // transformIgnorePatterns: [ 179 | // "\\\\node_modules\\\\", 180 | // "\\.pnp\\.[^\\\\]+$" 181 | // ], 182 | 183 | // An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them 184 | // unmockedModulePathPatterns: undefined, 185 | 186 | // Indicates whether each individual test should be reported during the run 187 | // verbose: undefined, 188 | 189 | // An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode 190 | // watchPathIgnorePatterns: [], 191 | 192 | // Whether to use watchman for file crawling 193 | // watchman: true, 194 | } 195 | -------------------------------------------------------------------------------- /public/icons/bkp/body.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | --------------------------------------------------------------------------------