From c5b1a01fd15e186bfdbb5f9f369a9ed45f168581 Mon Sep 17 00:00:00 2001 From: DTieman Date: Wed, 15 Mar 2023 14:44:11 +0100 Subject: [PATCH] sass setup + stole github button css >:) --- package-lock.json | 37 ++ package.json | 1 + src/App.css | 38 -- src/App.tsx | 2 +- src/index.tsx | 1 - src/layout/components/Button.tsx | 13 + src/layout/pages/Home.tsx | 13 +- src/layout/pages/Room.tsx | 6 + src/styles/App.scss | 2 + src/styles/layout/_layout.scss | 2 + src/styles/layout/components/_components.scss | 1 + src/styles/layout/components/button.scss | 56 +++ src/styles/layout/pages/_pages.scss | 0 src/styles/vendor/_vendor.scss | 1 + src/styles/vendor/normalize.scss | 352 ++++++++++++++++++ 15 files changed, 476 insertions(+), 49 deletions(-) delete mode 100644 src/App.css create mode 100644 src/layout/components/Button.tsx create mode 100644 src/styles/App.scss create mode 100644 src/styles/layout/_layout.scss create mode 100644 src/styles/layout/components/_components.scss create mode 100644 src/styles/layout/components/button.scss create mode 100644 src/styles/layout/pages/_pages.scss create mode 100644 src/styles/vendor/_vendor.scss create mode 100644 src/styles/vendor/normalize.scss diff --git a/package-lock.json b/package-lock.json index 7050681..be99196 100644 --- a/package-lock.json +++ b/package-lock.json @@ -22,6 +22,7 @@ "react-router-dom": "^6.9.0", "react-scripts": "5.0.1", "react-use-websocket": "^4.3.1", + "sass": "^1.59.3", "typescript": "^4.9.5", "web-vitals": "^2.1.4" } @@ -8809,6 +8810,11 @@ "url": "https://opencollective.com/immer" } }, + "node_modules/immutable": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/immutable/-/immutable-4.3.0.tgz", + "integrity": "sha512-0AOCmOip+xgJwEVTQj1EfiDDOkPmuyllDuTuEX+DDXUgapLAsBIfkg3sxCYyCEA8mQqZrrxPUGjcOQ2JS3WLkg==" + }, "node_modules/import-fresh": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz", @@ -14788,6 +14794,22 @@ "resolved": "https://registry.npmjs.org/sanitize.css/-/sanitize.css-13.0.0.tgz", "integrity": "sha512-ZRwKbh/eQ6w9vmTjkuG0Ioi3HBwPFce0O+v//ve+aOq1oeCy7jMV2qzzAlpsNuqpqCBjjriM1lbtZbF/Q8jVyA==" }, + "node_modules/sass": { + "version": "1.59.3", + "resolved": "https://registry.npmjs.org/sass/-/sass-1.59.3.tgz", + "integrity": "sha512-QCq98N3hX1jfTCoUAsF3eyGuXLsY7BCnCEg9qAact94Yc21npG2/mVOqoDvE0fCbWDqiM4WlcJQla0gWG2YlxQ==", + "dependencies": { + "chokidar": ">=3.0.0 <4.0.0", + "immutable": "^4.0.0", + "source-map-js": ">=0.6.2 <2.0.0" + }, + "bin": { + "sass": "sass.js" + }, + "engines": { + "node": ">=12.0.0" + } + }, "node_modules/sass-loader": { "version": "12.6.0", "resolved": "https://registry.npmjs.org/sass-loader/-/sass-loader-12.6.0.tgz", @@ -23410,6 +23432,11 @@ "resolved": "https://registry.npmjs.org/immer/-/immer-9.0.19.tgz", "integrity": "sha512-eY+Y0qcsB4TZKwgQzLaE/lqYMlKhv5J9dyd2RhhtGhNo2njPXDqU9XPfcNfa3MIDsdtZt5KlkIsirlo4dHsWdQ==" }, + "immutable": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/immutable/-/immutable-4.3.0.tgz", + "integrity": "sha512-0AOCmOip+xgJwEVTQj1EfiDDOkPmuyllDuTuEX+DDXUgapLAsBIfkg3sxCYyCEA8mQqZrrxPUGjcOQ2JS3WLkg==" + }, "import-fresh": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz", @@ -27522,6 +27549,16 @@ "resolved": "https://registry.npmjs.org/sanitize.css/-/sanitize.css-13.0.0.tgz", "integrity": "sha512-ZRwKbh/eQ6w9vmTjkuG0Ioi3HBwPFce0O+v//ve+aOq1oeCy7jMV2qzzAlpsNuqpqCBjjriM1lbtZbF/Q8jVyA==" }, + "sass": { + "version": "1.59.3", + "resolved": "https://registry.npmjs.org/sass/-/sass-1.59.3.tgz", + "integrity": "sha512-QCq98N3hX1jfTCoUAsF3eyGuXLsY7BCnCEg9qAact94Yc21npG2/mVOqoDvE0fCbWDqiM4WlcJQla0gWG2YlxQ==", + "requires": { + "chokidar": ">=3.0.0 <4.0.0", + "immutable": "^4.0.0", + "source-map-js": ">=0.6.2 <2.0.0" + } + }, "sass-loader": { "version": "12.6.0", "resolved": "https://registry.npmjs.org/sass-loader/-/sass-loader-12.6.0.tgz", diff --git a/package.json b/package.json index 50465ea..47e35c6 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "react-router-dom": "^6.9.0", "react-scripts": "5.0.1", "react-use-websocket": "^4.3.1", + "sass": "^1.59.3", "typescript": "^4.9.5", "web-vitals": "^2.1.4" }, diff --git a/src/App.css b/src/App.css deleted file mode 100644 index 74b5e05..0000000 --- a/src/App.css +++ /dev/null @@ -1,38 +0,0 @@ -.App { - text-align: center; -} - -.App-logo { - height: 40vmin; - pointer-events: none; -} - -@media (prefers-reduced-motion: no-preference) { - .App-logo { - animation: App-logo-spin infinite 20s linear; - } -} - -.App-header { - background-color: #282c34; - min-height: 100vh; - display: flex; - flex-direction: column; - align-items: center; - justify-content: center; - font-size: calc(10px + 2vmin); - color: white; -} - -.App-link { - color: #61dafb; -} - -@keyframes App-logo-spin { - from { - transform: rotate(0deg); - } - to { - transform: rotate(360deg); - } -} diff --git a/src/App.tsx b/src/App.tsx index 383ab1a..6e8c7fc 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import './App.css'; +import '../src/styles/App.scss'; import Router from "./config/Router"; function App() { diff --git a/src/index.tsx b/src/index.tsx index 23b3422..d77cdf9 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -1,6 +1,5 @@ import React from 'react'; import ReactDOM from 'react-dom/client'; -import './index.css'; import App from './App'; const root = ReactDOM.createRoot( diff --git a/src/layout/components/Button.tsx b/src/layout/components/Button.tsx new file mode 100644 index 0000000..f8fc6e8 --- /dev/null +++ b/src/layout/components/Button.tsx @@ -0,0 +1,13 @@ +import React, {FunctionComponent} from "react"; + +interface Props { + className?: string + onClick?: () => void + children?: React.ReactNode +} + +export const GHButton: FunctionComponent = ({className, onClick, children}) => { + return ( + {children} + ); +} \ No newline at end of file diff --git a/src/layout/pages/Home.tsx b/src/layout/pages/Home.tsx index 5c63fe8..5ade6fe 100644 --- a/src/layout/pages/Home.tsx +++ b/src/layout/pages/Home.tsx @@ -1,4 +1,5 @@ import React from "react"; +import {GHButton} from "../components/Button"; const ROOM_URL = 'http://localhost:5062/room'; @@ -8,14 +9,8 @@ const Home = () => { React.useEffect(() => { fetch(ROOM_URL) - .then((r) => { - console.log(r); - return r.json(); - }) - .then((data) => { - console.log(data); - setRooms(data); - }); + .then(r => r.json()) + .then(data => setRooms(data)); }, []); const handleCreateRoom = () => { @@ -32,7 +27,7 @@ const Home = () => { return (
- + Create Room
    { rooms.map((room, index) => { diff --git a/src/layout/pages/Room.tsx b/src/layout/pages/Room.tsx index 203d545..bbd0cf0 100644 --- a/src/layout/pages/Room.tsx +++ b/src/layout/pages/Room.tsx @@ -1,6 +1,7 @@ import useWebSocket from "react-use-websocket"; import React from "react"; import {useParams} from "react-router"; +import {GHButton} from "../components/Button"; const Room = () => { @@ -29,9 +30,14 @@ const Room = () => { setMessage(event.target.value); } + const handleLeaveRoom = () => { + window.location.href = '/'; + } + return (

    Room {roomId}

    + Leave Room
    diff --git a/src/styles/App.scss b/src/styles/App.scss new file mode 100644 index 0000000..5c27e0c --- /dev/null +++ b/src/styles/App.scss @@ -0,0 +1,2 @@ +@import "vendor/vendor"; +@import "layout/layout"; \ No newline at end of file diff --git a/src/styles/layout/_layout.scss b/src/styles/layout/_layout.scss new file mode 100644 index 0000000..7078505 --- /dev/null +++ b/src/styles/layout/_layout.scss @@ -0,0 +1,2 @@ +@import "pages/pages"; +@import "components/components"; \ No newline at end of file diff --git a/src/styles/layout/components/_components.scss b/src/styles/layout/components/_components.scss new file mode 100644 index 0000000..14eca13 --- /dev/null +++ b/src/styles/layout/components/_components.scss @@ -0,0 +1 @@ +@import "button"; \ No newline at end of file diff --git a/src/styles/layout/components/button.scss b/src/styles/layout/components/button.scss new file mode 100644 index 0000000..d60cc65 --- /dev/null +++ b/src/styles/layout/components/button.scss @@ -0,0 +1,56 @@ +.gh-button { + appearance: none; + background-color: #FAFBFC; + border: 1px solid rgba(27, 31, 35, 0.15); + border-radius: 6px; + box-shadow: rgba(27, 31, 35, 0.04) 0 1px 0, rgba(255, 255, 255, 0.25) 0 1px 0 inset; + box-sizing: border-box; + color: #24292E; + cursor: pointer; + display: inline-block; + font-family: -apple-system, system-ui, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; + font-size: 14px; + font-weight: 500; + line-height: 20px; + list-style: none; + padding: 6px 16px; + position: relative; + transition: background-color 0.2s cubic-bezier(0.3, 0, 0.5, 1); + user-select: none; + -webkit-user-select: none; + touch-action: manipulation; + vertical-align: middle; + white-space: nowrap; + word-wrap: break-word; + + :hover { + background-color: #F3F4F6; + text-decoration: none; + transition-duration: 0.1s; + } + + :disabled { + background-color: #FAFBFC; + border-color: rgba(27, 31, 35, 0.15); + color: #959DA5; + cursor: default; + } + + :active { + background-color: #EDEFF2; + box-shadow: rgba(225, 228, 232, 0.2) 0 1px 0 inset; + transition: none 0s; + } + + :focus { + outline: 1px transparent; + } + + :before { + display: none; + } + + ::-webkit-details-marker { + display: none; + } +} \ No newline at end of file diff --git a/src/styles/layout/pages/_pages.scss b/src/styles/layout/pages/_pages.scss new file mode 100644 index 0000000..e69de29 diff --git a/src/styles/vendor/_vendor.scss b/src/styles/vendor/_vendor.scss new file mode 100644 index 0000000..c1f8270 --- /dev/null +++ b/src/styles/vendor/_vendor.scss @@ -0,0 +1 @@ +@import "normalize"; \ No newline at end of file diff --git a/src/styles/vendor/normalize.scss b/src/styles/vendor/normalize.scss new file mode 100644 index 0000000..e515584 --- /dev/null +++ b/src/styles/vendor/normalize.scss @@ -0,0 +1,352 @@ +/*! normalize.css v8.0.1 | MIT License | github.com/necolas/normalize.css */ + +/* Document + ========================================================================== */ + +/** + * 1. Correct the line height in all browsers. + * 2. Prevent adjustments of font size after orientation changes in iOS. + */ + +html { + line-height: 1.15; /* 1 */ + -webkit-text-size-adjust: 100%; /* 2 */ +} + +/* Sections + ========================================================================== */ + +/** + * Remove the margin in all browsers. + */ + +body { + margin: 0; +} + +/** + * Render the `main` element consistently in IE. + */ + +main { + display: block; +} + +/** + * Correct the font size and margin on `h1` elements within `section` and + * `article` contexts in Chrome, Firefox, and Safari. + */ + +h1 { + font-size: 2em; + margin: 0.67em 0; +} + +/* Grouping content + ========================================================================== */ + +/** + * 1. Add the correct box sizing in Firefox. + * 2. Show the overflow in Edge and IE. + */ + +hr { + box-sizing: content-box; /* 1 */ + height: 0; /* 1 */ + overflow: visible; /* 2 */ +} + +/** + * 1. Correct the inheritance and scaling of font size in all browsers. + * 2. Correct the odd `em` font sizing in all browsers. + */ + +pre { + font-family: monospace, monospace; /* 1 */ + font-size: 1em; /* 2 */ +} + +/* Text-level semantics + ========================================================================== */ + +/** + * Remove the gray background on active links in IE 10. + */ + +a { + background-color: transparent; +} + +/** + * 1. Remove the bottom border in Chrome 57- + * 2. Add the correct text decoration in Chrome, Edge, IE, Opera, and Safari. + */ + +abbr[title] { + border-bottom: none; /* 1 */ + text-decoration: underline; /* 2 */ +} + +/** + * Add the correct font weight in Chrome, Edge, and Safari. + */ + +b, +strong { + font-weight: bolder; +} + +/** + * 1. Correct the inheritance and scaling of font size in all browsers. + * 2. Correct the odd `em` font sizing in all browsers. + */ + +code, +kbd, +samp { + font-family: monospace, monospace; /* 1 */ + font-size: 1em; /* 2 */ +} + +/** + * Add the correct font size in all browsers. + */ + +small { + font-size: 80%; +} + +/** + * Prevent `sub` and `sup` elements from affecting the line height in + * all browsers. + */ + +sub, +sup { + font-size: 75%; + line-height: 0; + position: relative; + vertical-align: baseline; +} + +sub { + bottom: -0.25em; +} + +sup { + top: -0.5em; +} + +/* Embedded content + ========================================================================== */ + +/** + * Remove the border on images inside links in IE 10. + */ + +img { + border-style: none; +} + +/* Forms + ========================================================================== */ + +/** + * 1. Change the font styles in all browsers. + * 2. Remove the margin in Firefox and Safari. + */ + +button, +input, +optgroup, +select, +textarea { + font-family: inherit; /* 1 */ + font-size: 100%; /* 1 */ + line-height: 1.15; /* 1 */ + margin: 0; /* 2 */ +} + +/** + * Show the overflow in IE. + * 1. Show the overflow in Edge. + */ + +button, +input { /* 1 */ + overflow: visible; +} + +/** + * Remove the inheritance of text transform in Edge, Firefox, and IE. + * 1. Remove the inheritance of text transform in Firefox. + */ + +button, +select { /* 1 */ + text-transform: none; +} + +/** + * Correct the inability to style clickable types in iOS and Safari. + */ + +button, +[type="button"], +[type="reset"], +[type="submit"] { + -webkit-appearance: button; +} + +/** + * Remove the inner border and padding in Firefox. + */ + +button::-moz-focus-inner, +[type="button"]::-moz-focus-inner, +[type="reset"]::-moz-focus-inner, +[type="submit"]::-moz-focus-inner { + border-style: none; + padding: 0; +} + +/** + * Restore the focus styles unset by the previous rule. + */ + +button:-moz-focusring, +[type="button"]:-moz-focusring, +[type="reset"]:-moz-focusring, +[type="submit"]:-moz-focusring { + outline: 1px dotted ButtonText; +} + +/** + * Correct the padding in Firefox. + */ + +fieldset { + padding: 0.35em 0.75em 0.625em; +} + +/** + * 1. Correct the text wrapping in Edge and IE. + * 2. Correct the color inheritance from `fieldset` elements in IE. + * 3. Remove the padding so developers are not caught out when they zero out + * `fieldset` elements in all browsers. + */ + +legend { + box-sizing: border-box; /* 1 */ + color: inherit; /* 2 */ + display: table; /* 1 */ + max-width: 100%; /* 1 */ + padding: 0; /* 3 */ + white-space: normal; /* 1 */ +} + +/** + * Add the correct vertical alignment in Chrome, Firefox, and Opera. + */ + +progress { + vertical-align: baseline; +} + +/** + * Remove the default vertical scrollbar in IE 10+. + */ + +textarea { + overflow: auto; +} + +/** + * 1. Add the correct box sizing in IE 10. + * 2. Remove the padding in IE 10. + */ + +[type="checkbox"], +[type="radio"] { + box-sizing: border-box; /* 1 */ + padding: 0; /* 2 */ +} + +/** + * Correct the cursor style of increment and decrement buttons in Chrome. + */ + +[type="number"]::-webkit-inner-spin-button, +[type="number"]::-webkit-outer-spin-button { + height: auto; +} + +/** + * 1. Correct the odd appearance in Chrome and Safari. + * 2. Correct the outline style in Safari. + */ + +[type="search"] { + -webkit-appearance: textfield; /* 1 */ + outline-offset: -2px; /* 2 */ +} + +/** + * Remove the inner padding in Chrome and Safari on macOS. + */ + +[type="search"]::-webkit-search-decoration { + -webkit-appearance: none; +} + +/** + * 1. Correct the inability to style clickable types in iOS and Safari. + * 2. Change font properties to `inherit` in Safari. + */ + +::-webkit-file-upload-button { + -webkit-appearance: button; /* 1 */ + font: inherit; /* 2 */ +} + +/* Interactive + ========================================================================== */ + +/* + * Add the correct display in Edge, IE 10+, and Firefox. + */ + +details { + display: block; +} + +/* + * Add the correct display in all browsers. + */ + +summary { + display: list-item; +} + +/* Misc + ========================================================================== */ + +/** + * Add the correct display in IE 10+. + */ + +template { + display: none; +} + +/** + * Add the correct display in IE 10. + */ + +[hidden] { + display: none; +} + +.layout { + height: 100%; +} \ No newline at end of file