Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions challenges/week-3/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module.exports = {
env: { browser: true, es2020: true },
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:react-hooks/recommended',
],
parser: '@typescript-eslint/parser',
parserOptions: { ecmaVersion: 'latest', sourceType: 'module' },
plugins: ['react-refresh'],
rules: {
'react-refresh/only-export-components': 'warn',
},
}
24 changes: 24 additions & 0 deletions challenges/week-3/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
19 changes: 19 additions & 0 deletions challenges/week-3/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Work+Sans:wght@400;700;900&display=swap" rel="stylesheet">
<title>Confirmation Modal</title>
</head>

<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>

</html>
28 changes: 28 additions & 0 deletions challenges/week-3/package copy.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "week3",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"lint": "eslint src --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview"
},
"dependencies": {
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@types/react": "^18.0.28",
"@types/react-dom": "^18.0.11",
"@typescript-eslint/eslint-plugin": "^5.57.1",
"@typescript-eslint/parser": "^5.57.1",
"@vitejs/plugin-react": "^4.0.0",
"eslint": "^8.38.0",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.3.4",
"typescript": "^5.0.2",
"vite": "^4.3.2"
}
}
31 changes: 26 additions & 5 deletions challenges/week-3/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,28 @@
{
"name": "week-3-challenge",
"version": "1.0.0",
"description": "Confirmation modal",
"author": "Nerdbord",
"license": "ISC"
"name": "week3",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"lint": "eslint src --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview"
},
"dependencies": {
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@types/react": "^18.0.28",
"@types/react-dom": "^18.0.11",
"@typescript-eslint/eslint-plugin": "^5.57.1",
"@typescript-eslint/parser": "^5.57.1",
"@vitejs/plugin-react": "^4.0.0",
"eslint": "^8.38.0",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.3.4",
"typescript": "^5.0.2",
"vite": "^4.3.2"
}
}
1 change: 1 addition & 0 deletions challenges/week-3/public/vite.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions challenges/week-3/src/assets/react.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions challenges/week-3/src/component/app/App.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.modal--container {
display: flex;
align-items: center;
justify-content: center;
height: 100%;
width: 100%;
}
.modal--background {
background-color: var(--grayBacground);
}
24 changes: 24 additions & 0 deletions challenges/week-3/src/component/app/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { useState } from 'react';
import './App.css';
import InitialDisplay from '../initialDisplay/InitialDisplay';
import Modal from '../modal/Modal';

function App() {
const [isClicked, setIsClicked] = useState(false);

return (
<section
className={
isClicked ? 'modal--container modal--background' : 'modal--container '
}
>
{isClicked ? (
<Modal isClicked={isClicked} setIsClicked={setIsClicked} />
) : (
<InitialDisplay setIsClicked={setIsClicked} />
)}
</section>
);
}

export default App;
16 changes: 16 additions & 0 deletions challenges/week-3/src/component/initialDisplay/InitialDisplay.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { InitialProps } from '../../types/types';
import './initialDisplay.css'
const InitialDisplay = ({ setIsClicked }: InitialProps) => {
const handleOpenModal = () => {
setIsClicked(true);
};
return (
<div className='initial-text--container'>
<p className='initial--text'>Pop me up like one of your bubble wraps.</p>
<button onClick={handleOpenModal} className='initial--button'>
pop it!
</button>
</div>
);
};
export default InitialDisplay;
32 changes: 32 additions & 0 deletions challenges/week-3/src/component/initialDisplay/initialDisplay.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
.initial-text--container {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
max-width: 340px;
height: auto;
padding: 55px;
}
.initial--text {
color: var(--fontColor);
font-size: 14px;
font-weight: 500;
margin-bottom: 20px;
text-align: center;
}
.initial--button {
background-color: var(--purple);
border: none;
border-radius: 40px;
color: var(--lightPurple);
cursor: pointer;
font-size: 14px;
font-weight: 500;
padding: 10px 30px;
text-transform: uppercase;
transition: background-color 0.3s, color 0.3s;
}
.initial--button:hover {
background-color: var(--lightPurple);
color: var(--purple);
}
23 changes: 23 additions & 0 deletions challenges/week-3/src/component/modal/Modal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { ModalProps } from '../../types/types';

import './modal.css';

const Modal = ({ isClicked, setIsClicked }: ModalProps) => {
const handleCloseModal = () => {
setIsClicked(false);
};
return (
<div
className={
isClicked ? 'modal modal--animation' : 'modal modal--closeAnimation'
}
>
<p className='modal--text'>Wow, bouncy!</p>
<p className='modal--text'>Now, let’s wrap it up and close me back.</p>
<button onClick={handleCloseModal} className='modal--button'>
Let’s close
</button>
</div>
);
};
export default Modal;
55 changes: 55 additions & 0 deletions challenges/week-3/src/component/modal/modal.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
.modal {
background-color: var(--lightGray);
box-shadow: 0px 4px 24px rgba(0, 0, 0, 0.15);
border-radius: 10px;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 75px;
}
.modal--animation {
animation: modalAnimation 0.8s;
}
.modal--button {
background-color: var(--purple);
border: none;
border-radius: 40px;
color: var(--lightPurple);
cursor: pointer;
font-size: 14px;
font-weight: 500;
margin-top: 20px;
padding: 10px 30px;
text-transform: uppercase;
transition: background-color 0.3s, color 0.3s;
}
.modal--button:hover {
background-color: var(--lightPurple);
color: var(--purple);
}
.modal--text {
font-size: 20px;
font-weight: 500;
}

@keyframes modalAnimation {
0% {
transform: scale(0, 0);
opacity: 0;
}
25% {
transform: scale(1.1, 1.1);
}
50% {
transform: scale(1, 1);
opacity: 0.5;
}
75% {
transform: scale(1.1, 1.1);
}
100% {
transform: scale(1, 1);
opacity: 1;
}
}
21 changes: 21 additions & 0 deletions challenges/week-3/src/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
:root {
--lightGray: rgba(255, 255, 255, 1);
--fontColor: rgba(0, 0, 0, 1);
--grayBacground: rgba(0, 0, 0, 0.5);
--lightPurple: rgba(220, 222, 253, 1);
--purple: rgba(106, 110, 247, 1);
}
html,
body,
#root {
height: 100%;
width: 100%;
}
body {
font-family: 'Work Sans', sans-serif;
}
10 changes: 10 additions & 0 deletions challenges/week-3/src/main.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import React from 'react'
import ReactDOM from 'react-dom/client'
import App from './component/app/App'
import './index.css'

ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(
<React.StrictMode>
<App />
</React.StrictMode>,
)
8 changes: 8 additions & 0 deletions challenges/week-3/src/types/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
interface ModalProps {
isClicked: boolean;
setIsClicked: (isClicked: boolean) => void;
}
interface InitialProps {
setIsClicked: (isClicked: boolean) => void;
}
export type { InitialProps, ModalProps };
1 change: 1 addition & 0 deletions challenges/week-3/src/vite-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference types="vite/client" />
24 changes: 24 additions & 0 deletions challenges/week-3/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"compilerOptions": {
"target": "ESNext",
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"module": "ESNext",
"skipLibCheck": true,

/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",

/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
},
"include": ["src"],
"references": [{ "path": "./tsconfig.node.json" }]
}
10 changes: 10 additions & 0 deletions challenges/week-3/tsconfig.node.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"compilerOptions": {
"composite": true,
"skipLibCheck": true,
"module": "ESNext",
"moduleResolution": "bundler",
"allowSyntheticDefaultImports": true
},
"include": ["vite.config.ts"]
}
7 changes: 7 additions & 0 deletions challenges/week-3/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'

// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
})
Loading