Skip to content

Commit

Permalink
Merge branch 'refactor-layout'
Browse files Browse the repository at this point in the history
  • Loading branch information
ElynnaChuang committed May 14, 2023
2 parents c85a41d + 22837a9 commit 216c6da
Show file tree
Hide file tree
Showing 46 changed files with 580 additions and 793 deletions.
1 change: 1 addition & 0 deletions .stylelintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"scss/dollar-variable-pattern": null,
"scss/percent-placeholder-pattern": null,
"scss/no-global-function-names": null,
"scss/at-extend-no-missing-placeholder": null,
"property-no-vendor-prefix": [
true,
{ "ignoreProperties": ["background-clip", "backdrop-filter"] }
Expand Down
2 changes: 0 additions & 2 deletions src/App.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
@use './scss/reset';

@import './scss/media';

html,
body {
font-family: Lato, 'Noto Sans TC', sans-serif;
Expand Down
6 changes: 2 additions & 4 deletions src/Components/14Example/styles.module.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
@import '../../scss/color';

.example {
display: flex;
flex-direction: column;
Expand All @@ -8,13 +6,13 @@
& h4 {
font-size: 1.25rem;
font-weight: 500;
color: $primary;
color: #3479be;
}

& p {
font-size: 1rem;
line-height: 140%;
color: $primary;
color: #3479be;
letter-spacing: 1px;
}

Expand Down
18 changes: 18 additions & 0 deletions src/Components/Titles/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import styles from './styles.module.scss';

const Title = ({ title, subtitle, titleColor, titleClassName, size }) => {
let titleSize = styles.title_L;
if (size === 'm') titleSize = styles.title_M;
if (size === 's') titleSize = styles.title_S;

return (
<div className={`${styles.title_container} ${titleClassName}`}>
<h1 className={titleSize} style={{ color: titleColor }}>
{title}
</h1>
{subtitle && <p className={styles.subtitle}>{subtitle}</p>}
</div>
);
};

export { Title };
44 changes: 44 additions & 0 deletions src/Components/Titles/styles.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
@use '../../scss/space' as space;
@use '../../scss/font' as font;

.title_container {
display: flex;
flex-direction: column;
gap: space.$space_1;

width: 100%;

text-align: center;
}

.title {
&_L {
font-size: font.$h1;
font-weight: 900;
line-height: 160%;
}

&_M {
font-size: font.$h2;
font-weight: 700;
line-height: 140%;
}

&_S {
font-size: font.$h3;
font-weight: 700;
line-height: 120%;
}
}

.subtitle {
font-size: font.$h4;
font-weight: 500;
line-height: 100%;
color: #747b88;

& a {
color: #747b88;
text-decoration: underline;
}
}
2 changes: 2 additions & 0 deletions src/Components/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,7 @@ export { Example } from './14Example';
export { Form } from './15Form';
export { List } from './15List';

export { Title } from './Titles';

export { Card } from './Card';
export { Image } from './Image';
12 changes: 12 additions & 0 deletions src/Layouts/LayoutCol1/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Image } from '@/Components';
import styles from './styles.module.scss';

export const LayoutCol1 = ({ baseClassName, children, bgImages, layout }) => {
const layoutClass = layout === 'full' ? styles.layout_full : styles.layout_center_col;
return (
<section className={`${styles.base} ${baseClassName}`}>
{bgImages && <Image images={bgImages} className={styles.bg} />}
<div className={layoutClass}>{children}</div>
</section>
);
};
45 changes: 45 additions & 0 deletions src/Layouts/LayoutCol1/styles.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
@use '../../scss/space' as space;

.base {
position: relative;
overflow-x: hidden;
overflow-y: scroll;
height: 100vh;

&::-webkit-scrollbar {
display: none;
}
}

.bg {
position: absolute;
top: 0;
left: 0;
width: 100%;
}

%base_layout {
position: relative;

display: flex;
flex-direction: column;
gap: space.$space_3;
align-items: center;

width: 100%;
padding: space.$space_3;
}

.layout_full {
@extend %base_layout;

justify-content: center;
height: 100%;
}

.layout_center_col {
@extend %base_layout;

max-width: 800px;
margin: 0 auto space.$space_3;
}
1 change: 1 addition & 0 deletions src/Layouts/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { LayoutCol1 } from './LayoutCol1';
57 changes: 26 additions & 31 deletions src/Pages/01Drums/index.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useEffect, useState } from 'react';

import { Key, Image } from '@/Components/index';
import { Key } from '@/Components/index';
import {
clap,
hihat,
Expand All @@ -15,6 +15,7 @@ import {
import baseImg from '@/Assets/01bg/base.jpg';
import webpImg from '@/Assets/01bg/base.webp';
import styles from './styles.module.scss';
import { LayoutCol1 } from '@/Layouts';

const keys = [
{ keyNum: 65, keyName: 'a', soundTag: 'clap' },
Expand All @@ -40,6 +41,17 @@ const sounds = {
l: new Audio(tink),
};

const images = {
base: baseImg,
l1x: webpImg,
l2x: webpImg,
m1x: webpImg,
m2x: webpImg,
s1x: webpImg,
s2x: webpImg,
s3x: webpImg,
};

const DrumPage = () => {
const [currentKey, setCurrentKey] = useState('');

Expand All @@ -64,38 +76,21 @@ const DrumPage = () => {
}, []);

return (
<section className={styles.page}>
<Image
images={{
base: baseImg,
l1x: webpImg,
l2x: webpImg,
m1x: webpImg,
m2x: webpImg,
s1x: webpImg,
s2x: webpImg,
s3x: webpImg,
}}
className={styles.bg}
/>
<LayoutCol1 baseClassName={styles.page} bgImages={images} layout='full'>
<p className={styles.caption}>Press your keyboard or tap the keys on the screen!</p>

<div className={styles.container}>
<h1 className={styles.caption}>
Press your keyboard or tap the keys on the screen!
</h1>
<div className={styles.keys}>
{keys.map(({ keyNum, keyName, soundTag }) => (
<Key
key={keyNum}
keyName={keyName}
soundTag={soundTag}
onClick={() => handlePlaySound(keyName)}
currentKey={currentKey}
/>
))}
</div>
<div className={styles.keys}>
{keys.map(({ keyNum, keyName, soundTag }) => (
<Key
key={keyNum}
keyName={keyName}
soundTag={soundTag}
onClick={() => handlePlaySound(keyName)}
currentKey={currentKey}
/>
))}
</div>
</section>
</LayoutCol1>
);
};

Expand Down
24 changes: 4 additions & 20 deletions src/Pages/01Drums/styles.module.scss
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
.page {
position: relative;
overflow: hidden;
width: 100%;
height: 100%;
}

.bg::after {
.page > div:first-child::after {
content: '';

position: absolute;
Expand All @@ -16,16 +9,7 @@
height: 100%;

background-color: rgba($color: #000, $alpha: 40%);
backdrop-filter: blur(8px) saturate(0.8);
}

.container {
position: absolute;
top: 50%;
transform: translate(0, -70%);

width: 100%;
padding: 0 4rem;
backdrop-filter: blur(8px) saturate(1);
}

.keys {
Expand All @@ -34,11 +18,11 @@
gap: 2rem;
align-items: center;
justify-content: center;
}

.caption {
margin-bottom: 4rem;
}

.caption {
font-family: monospace;
font-size: 1.2rem;
font-weight: 500;
Expand Down
Loading

0 comments on commit 216c6da

Please sign in to comment.