From c26471bc60e5d93070602ca8239da9ff71d96056 Mon Sep 17 00:00:00 2001 From: suminjeff Date: Tue, 10 Sep 2024 14:56:19 +0900 Subject: [PATCH 01/16] ex1 (chore) first commit --- .../ex1/book-edit.html" | 9 + .../ex1/index.html" | 9 + .../ex1/register.html" | 9 + .../ex1/src/input.css" | 3 + .../ex1/src/output.css" | 555 ++++++++++++++++++ .../ex1/tailwind.config.js" | 8 + 6 files changed, 593 insertions(+) create mode 100644 "\354\235\264\354\210\230\353\257\274/ex1/src/input.css" create mode 100644 "\354\235\264\354\210\230\353\257\274/ex1/src/output.css" create mode 100644 "\354\235\264\354\210\230\353\257\274/ex1/tailwind.config.js" diff --git "a/\354\235\264\354\210\230\353\257\274/ex1/book-edit.html" "b/\354\235\264\354\210\230\353\257\274/ex1/book-edit.html" index e69de29..24ad574 100644 --- "a/\354\235\264\354\210\230\353\257\274/ex1/book-edit.html" +++ "b/\354\235\264\354\210\230\353\257\274/ex1/book-edit.html" @@ -0,0 +1,9 @@ + + + + + + Document + + + diff --git "a/\354\235\264\354\210\230\353\257\274/ex1/index.html" "b/\354\235\264\354\210\230\353\257\274/ex1/index.html" index e69de29..24ad574 100644 --- "a/\354\235\264\354\210\230\353\257\274/ex1/index.html" +++ "b/\354\235\264\354\210\230\353\257\274/ex1/index.html" @@ -0,0 +1,9 @@ + + + + + + Document + + + diff --git "a/\354\235\264\354\210\230\353\257\274/ex1/register.html" "b/\354\235\264\354\210\230\353\257\274/ex1/register.html" index e69de29..24ad574 100644 --- "a/\354\235\264\354\210\230\353\257\274/ex1/register.html" +++ "b/\354\235\264\354\210\230\353\257\274/ex1/register.html" @@ -0,0 +1,9 @@ + + + + + + Document + + + diff --git "a/\354\235\264\354\210\230\353\257\274/ex1/src/input.css" "b/\354\235\264\354\210\230\353\257\274/ex1/src/input.css" new file mode 100644 index 0000000..b5c61c9 --- /dev/null +++ "b/\354\235\264\354\210\230\353\257\274/ex1/src/input.css" @@ -0,0 +1,3 @@ +@tailwind base; +@tailwind components; +@tailwind utilities; diff --git "a/\354\235\264\354\210\230\353\257\274/ex1/src/output.css" "b/\354\235\264\354\210\230\353\257\274/ex1/src/output.css" new file mode 100644 index 0000000..fb6b6ab --- /dev/null +++ "b/\354\235\264\354\210\230\353\257\274/ex1/src/output.css" @@ -0,0 +1,555 @@ +/* +! tailwindcss v3.4.10 | MIT License | https://tailwindcss.com +*/ + +/* +1. Prevent padding and border from affecting element width. (https://github.com/mozdevs/cssremedy/issues/4) +2. Allow adding a border to an element by just adding a border-width. (https://github.com/tailwindcss/tailwindcss/pull/116) +*/ + +*, +::before, +::after { + box-sizing: border-box; + /* 1 */ + border-width: 0; + /* 2 */ + border-style: solid; + /* 2 */ + border-color: #e5e7eb; + /* 2 */ +} + +::before, +::after { + --tw-content: ''; +} + +/* +1. Use a consistent sensible line-height in all browsers. +2. Prevent adjustments of font size after orientation changes in iOS. +3. Use a more readable tab size. +4. Use the user's configured `sans` font-family by default. +5. Use the user's configured `sans` font-feature-settings by default. +6. Use the user's configured `sans` font-variation-settings by default. +7. Disable tap highlights on iOS +*/ + +html, +:host { + line-height: 1.5; + /* 1 */ + -webkit-text-size-adjust: 100%; + /* 2 */ + -moz-tab-size: 4; + /* 3 */ + -o-tab-size: 4; + tab-size: 4; + /* 3 */ + font-family: ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; + /* 4 */ + font-feature-settings: normal; + /* 5 */ + font-variation-settings: normal; + /* 6 */ + -webkit-tap-highlight-color: transparent; + /* 7 */ +} + +/* +1. Remove the margin in all browsers. +2. Inherit line-height from `html` so users can set them as a class directly on the `html` element. +*/ + +body { + margin: 0; + /* 1 */ + line-height: inherit; + /* 2 */ +} + +/* +1. Add the correct height in Firefox. +2. Correct the inheritance of border color in Firefox. (https://bugzilla.mozilla.org/show_bug.cgi?id=190655) +3. Ensure horizontal rules are visible by default. +*/ + +hr { + height: 0; + /* 1 */ + color: inherit; + /* 2 */ + border-top-width: 1px; + /* 3 */ +} + +/* +Add the correct text decoration in Chrome, Edge, and Safari. +*/ + +abbr:where([title]) { + -webkit-text-decoration: underline dotted; + text-decoration: underline dotted; +} + +/* +Remove the default font size and weight for headings. +*/ + +h1, +h2, +h3, +h4, +h5, +h6 { + font-size: inherit; + font-weight: inherit; +} + +/* +Reset links to optimize for opt-in styling instead of opt-out. +*/ + +a { + color: inherit; + text-decoration: inherit; +} + +/* +Add the correct font weight in Edge and Safari. +*/ + +b, +strong { + font-weight: bolder; +} + +/* +1. Use the user's configured `mono` font-family by default. +2. Use the user's configured `mono` font-feature-settings by default. +3. Use the user's configured `mono` font-variation-settings by default. +4. Correct the odd `em` font sizing in all browsers. +*/ + +code, +kbd, +samp, +pre { + font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; + /* 1 */ + font-feature-settings: normal; + /* 2 */ + font-variation-settings: normal; + /* 3 */ + font-size: 1em; + /* 4 */ +} + +/* +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; +} + +/* +1. Remove text indentation from table contents in Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=999088, https://bugs.webkit.org/show_bug.cgi?id=201297) +2. Correct table border color inheritance in all Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=935729, https://bugs.webkit.org/show_bug.cgi?id=195016) +3. Remove gaps between table borders by default. +*/ + +table { + text-indent: 0; + /* 1 */ + border-color: inherit; + /* 2 */ + border-collapse: collapse; + /* 3 */ +} + +/* +1. Change the font styles in all browsers. +2. Remove the margin in Firefox and Safari. +3. Remove default padding in all browsers. +*/ + +button, +input, +optgroup, +select, +textarea { + font-family: inherit; + /* 1 */ + font-feature-settings: inherit; + /* 1 */ + font-variation-settings: inherit; + /* 1 */ + font-size: 100%; + /* 1 */ + font-weight: inherit; + /* 1 */ + line-height: inherit; + /* 1 */ + letter-spacing: inherit; + /* 1 */ + color: inherit; + /* 1 */ + margin: 0; + /* 2 */ + padding: 0; + /* 3 */ +} + +/* +Remove the inheritance of text transform in Edge and Firefox. +*/ + +button, +select { + text-transform: none; +} + +/* +1. Correct the inability to style clickable types in iOS and Safari. +2. Remove default button styles. +*/ + +button, +input:where([type='button']), +input:where([type='reset']), +input:where([type='submit']) { + -webkit-appearance: button; + /* 1 */ + background-color: transparent; + /* 2 */ + background-image: none; + /* 2 */ +} + +/* +Use the modern Firefox focus style for all focusable elements. +*/ + +:-moz-focusring { + outline: auto; +} + +/* +Remove the additional `:invalid` styles in Firefox. (https://github.com/mozilla/gecko-dev/blob/2f9eacd9d3d995c937b4251a5557d95d494c9be1/layout/style/res/forms.css#L728-L737) +*/ + +:-moz-ui-invalid { + box-shadow: none; +} + +/* +Add the correct vertical alignment in Chrome and Firefox. +*/ + +progress { + vertical-align: baseline; +} + +/* +Correct the cursor style of increment and decrement buttons in Safari. +*/ + +::-webkit-inner-spin-button, +::-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. +*/ + +::-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 */ +} + +/* +Add the correct display in Chrome and Safari. +*/ + +summary { + display: list-item; +} + +/* +Removes the default spacing and border for appropriate elements. +*/ + +blockquote, +dl, +dd, +h1, +h2, +h3, +h4, +h5, +h6, +hr, +figure, +p, +pre { + margin: 0; +} + +fieldset { + margin: 0; + padding: 0; +} + +legend { + padding: 0; +} + +ol, +ul, +menu { + list-style: none; + margin: 0; + padding: 0; +} + +/* +Reset default styling for dialogs. +*/ + +dialog { + padding: 0; +} + +/* +Prevent resizing textareas horizontally by default. +*/ + +textarea { + resize: vertical; +} + +/* +1. Reset the default placeholder opacity in Firefox. (https://github.com/tailwindlabs/tailwindcss/issues/3300) +2. Set the default placeholder color to the user's configured gray 400 color. +*/ + +input::-moz-placeholder, textarea::-moz-placeholder { + opacity: 1; + /* 1 */ + color: #9ca3af; + /* 2 */ +} + +input::placeholder, +textarea::placeholder { + opacity: 1; + /* 1 */ + color: #9ca3af; + /* 2 */ +} + +/* +Set the default cursor for buttons. +*/ + +button, +[role="button"] { + cursor: pointer; +} + +/* +Make sure disabled buttons don't get the pointer cursor. +*/ + +:disabled { + cursor: default; +} + +/* +1. Make replaced elements `display: block` by default. (https://github.com/mozdevs/cssremedy/issues/14) +2. Add `vertical-align: middle` to align replaced elements more sensibly by default. (https://github.com/jensimmons/cssremedy/issues/14#issuecomment-634934210) + This can trigger a poorly considered lint error in some tools but is included by design. +*/ + +img, +svg, +video, +canvas, +audio, +iframe, +embed, +object { + display: block; + /* 1 */ + vertical-align: middle; + /* 2 */ +} + +/* +Constrain images and videos to the parent width and preserve their intrinsic aspect ratio. (https://github.com/mozdevs/cssremedy/issues/14) +*/ + +img, +video { + max-width: 100%; + height: auto; +} + +/* Make elements with the HTML hidden attribute stay hidden by default */ + +[hidden] { + display: none; +} + +*, ::before, ::after { + --tw-border-spacing-x: 0; + --tw-border-spacing-y: 0; + --tw-translate-x: 0; + --tw-translate-y: 0; + --tw-rotate: 0; + --tw-skew-x: 0; + --tw-skew-y: 0; + --tw-scale-x: 1; + --tw-scale-y: 1; + --tw-pan-x: ; + --tw-pan-y: ; + --tw-pinch-zoom: ; + --tw-scroll-snap-strictness: proximity; + --tw-gradient-from-position: ; + --tw-gradient-via-position: ; + --tw-gradient-to-position: ; + --tw-ordinal: ; + --tw-slashed-zero: ; + --tw-numeric-figure: ; + --tw-numeric-spacing: ; + --tw-numeric-fraction: ; + --tw-ring-inset: ; + --tw-ring-offset-width: 0px; + --tw-ring-offset-color: #fff; + --tw-ring-color: rgb(59 130 246 / 0.5); + --tw-ring-offset-shadow: 0 0 #0000; + --tw-ring-shadow: 0 0 #0000; + --tw-shadow: 0 0 #0000; + --tw-shadow-colored: 0 0 #0000; + --tw-blur: ; + --tw-brightness: ; + --tw-contrast: ; + --tw-grayscale: ; + --tw-hue-rotate: ; + --tw-invert: ; + --tw-saturate: ; + --tw-sepia: ; + --tw-drop-shadow: ; + --tw-backdrop-blur: ; + --tw-backdrop-brightness: ; + --tw-backdrop-contrast: ; + --tw-backdrop-grayscale: ; + --tw-backdrop-hue-rotate: ; + --tw-backdrop-invert: ; + --tw-backdrop-opacity: ; + --tw-backdrop-saturate: ; + --tw-backdrop-sepia: ; + --tw-contain-size: ; + --tw-contain-layout: ; + --tw-contain-paint: ; + --tw-contain-style: ; +} + +::backdrop { + --tw-border-spacing-x: 0; + --tw-border-spacing-y: 0; + --tw-translate-x: 0; + --tw-translate-y: 0; + --tw-rotate: 0; + --tw-skew-x: 0; + --tw-skew-y: 0; + --tw-scale-x: 1; + --tw-scale-y: 1; + --tw-pan-x: ; + --tw-pan-y: ; + --tw-pinch-zoom: ; + --tw-scroll-snap-strictness: proximity; + --tw-gradient-from-position: ; + --tw-gradient-via-position: ; + --tw-gradient-to-position: ; + --tw-ordinal: ; + --tw-slashed-zero: ; + --tw-numeric-figure: ; + --tw-numeric-spacing: ; + --tw-numeric-fraction: ; + --tw-ring-inset: ; + --tw-ring-offset-width: 0px; + --tw-ring-offset-color: #fff; + --tw-ring-color: rgb(59 130 246 / 0.5); + --tw-ring-offset-shadow: 0 0 #0000; + --tw-ring-shadow: 0 0 #0000; + --tw-shadow: 0 0 #0000; + --tw-shadow-colored: 0 0 #0000; + --tw-blur: ; + --tw-brightness: ; + --tw-contrast: ; + --tw-grayscale: ; + --tw-hue-rotate: ; + --tw-invert: ; + --tw-saturate: ; + --tw-sepia: ; + --tw-drop-shadow: ; + --tw-backdrop-blur: ; + --tw-backdrop-brightness: ; + --tw-backdrop-contrast: ; + --tw-backdrop-grayscale: ; + --tw-backdrop-hue-rotate: ; + --tw-backdrop-invert: ; + --tw-backdrop-opacity: ; + --tw-backdrop-saturate: ; + --tw-backdrop-sepia: ; + --tw-contain-size: ; + --tw-contain-layout: ; + --tw-contain-paint: ; + --tw-contain-style: ; +} diff --git "a/\354\235\264\354\210\230\353\257\274/ex1/tailwind.config.js" "b/\354\235\264\354\210\230\353\257\274/ex1/tailwind.config.js" new file mode 100644 index 0000000..19973dd --- /dev/null +++ "b/\354\235\264\354\210\230\353\257\274/ex1/tailwind.config.js" @@ -0,0 +1,8 @@ +/** @type {import('tailwindcss').Config} */ +module.exports = { + content: ["./src/**/*.{html,js}"], + theme: { + extend: {}, + }, + plugins: [], +}; From 4e72a561bfa58f50fb6378aab9fe5426abeb0ab8 Mon Sep 17 00:00:00 2001 From: suminjeff Date: Tue, 10 Sep 2024 17:09:43 +0900 Subject: [PATCH 02/16] ex1 (feat) navbar 1st draft completed --- .../ex1/book-edit.html" | 47 +++++++- .../ex1/input.css" | 4 + .../ex1/output.css" | 107 ++++++++++++++++++ .../ex1/static/bookmark_logo.svg" | 6 + .../ex1/tailwind.config.js" | 2 +- 5 files changed, 164 insertions(+), 2 deletions(-) rename "\354\235\264\354\210\230\353\257\274/ex1/src/input.css" => "\354\235\264\354\210\230\353\257\274/ex1/input.css" (71%) rename "\354\235\264\354\210\230\353\257\274/ex1/src/output.css" => "\354\235\264\354\210\230\353\257\274/ex1/output.css" (90%) create mode 100644 "\354\235\264\354\210\230\353\257\274/ex1/static/bookmark_logo.svg" diff --git "a/\354\235\264\354\210\230\353\257\274/ex1/book-edit.html" "b/\354\235\264\354\210\230\353\257\274/ex1/book-edit.html" index 24ad574..76e3f1e 100644 --- "a/\354\235\264\354\210\230\353\257\274/ex1/book-edit.html" +++ "b/\354\235\264\354\210\230\353\257\274/ex1/book-edit.html" @@ -4,6 +4,51 @@ Document + - + + + + + + +
+
01
+
+ + + +
+ + diff --git "a/\354\235\264\354\210\230\353\257\274/ex1/src/input.css" "b/\354\235\264\354\210\230\353\257\274/ex1/input.css" similarity index 71% rename from "\354\235\264\354\210\230\353\257\274/ex1/src/input.css" rename to "\354\235\264\354\210\230\353\257\274/ex1/input.css" index b5c61c9..e657cbf 100644 --- "a/\354\235\264\354\210\230\353\257\274/ex1/src/input.css" +++ "b/\354\235\264\354\210\230\353\257\274/ex1/input.css" @@ -1,3 +1,7 @@ @tailwind base; @tailwind components; @tailwind utilities; + +body { + margin: 0%; +} diff --git "a/\354\235\264\354\210\230\353\257\274/ex1/src/output.css" "b/\354\235\264\354\210\230\353\257\274/ex1/output.css" similarity index 90% rename from "\354\235\264\354\210\230\353\257\274/ex1/src/output.css" rename to "\354\235\264\354\210\230\353\257\274/ex1/output.css" index fb6b6ab..0a5eebf 100644 --- "a/\354\235\264\354\210\230\353\257\274/ex1/src/output.css" +++ "b/\354\235\264\354\210\230\353\257\274/ex1/output.css" @@ -553,3 +553,110 @@ video { --tw-contain-paint: ; --tw-contain-style: ; } + +.flex { + display: flex; +} + +.grid { + display: grid; +} + +.h-16 { + height: 4rem; +} + +.h-6 { + height: 1.5rem; +} + +.h-full { + height: 100%; +} + +.h-max { + height: -moz-max-content; + height: max-content; +} + +.max-h-max { + max-height: -moz-max-content; + max-height: max-content; +} + +.w-1\/4 { + width: 25%; +} + +.w-6 { + width: 1.5rem; +} + +.grid-cols-4 { + grid-template-columns: repeat(4, minmax(0, 1fr)); +} + +.justify-center { + justify-content: center; +} + +.justify-between { + justify-content: space-between; +} + +.gap-4 { + gap: 1rem; +} + +.gap-2 { + gap: 0.5rem; +} + +.self-center { + align-self: center; +} + +.rounded { + border-radius: 0.25rem; +} + +.border-b-2 { + border-bottom-width: 2px; +} + +.bg-gray-100 { + --tw-bg-opacity: 1; + background-color: rgb(243 244 246 / var(--tw-bg-opacity)); +} + +.bg-red-600 { + --tw-bg-opacity: 1; + background-color: rgb(220 38 38 / var(--tw-bg-opacity)); +} + +.p-3 { + padding: 0.75rem; +} + +.px-8 { + padding-left: 2rem; + padding-right: 2rem; +} + +.py-1 { + padding-top: 0.25rem; + padding-bottom: 0.25rem; +} + +.text-2xl { + font-size: 1.5rem; + line-height: 2rem; +} + +.font-semibold { + font-weight: 600; +} + +body { + margin: 0%; +} diff --git "a/\354\235\264\354\210\230\353\257\274/ex1/static/bookmark_logo.svg" "b/\354\235\264\354\210\230\353\257\274/ex1/static/bookmark_logo.svg" new file mode 100644 index 0000000..fa99457 --- /dev/null +++ "b/\354\235\264\354\210\230\353\257\274/ex1/static/bookmark_logo.svg" @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git "a/\354\235\264\354\210\230\353\257\274/ex1/tailwind.config.js" "b/\354\235\264\354\210\230\353\257\274/ex1/tailwind.config.js" index 19973dd..ab3e021 100644 --- "a/\354\235\264\354\210\230\353\257\274/ex1/tailwind.config.js" +++ "b/\354\235\264\354\210\230\353\257\274/ex1/tailwind.config.js" @@ -1,6 +1,6 @@ /** @type {import('tailwindcss').Config} */ module.exports = { - content: ["./src/**/*.{html,js}"], + content: ["./**/*.{html,js}"], theme: { extend: {}, }, From b8364a362b21ab390097958e4ee160e1c6c356d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=88=98=EB=AF=BC?= Date: Wed, 11 Sep 2024 14:53:51 +0900 Subject: [PATCH 03/16] ex2 (feat) completed --- "\354\235\264\354\210\230\353\257\274/ex2.js" | 60 ++++++++++++++++++- .../ex2.test.js" | 4 +- .../ex3.test.js" | 6 +- 3 files changed, 64 insertions(+), 6 deletions(-) diff --git "a/\354\235\264\354\210\230\353\257\274/ex2.js" "b/\354\235\264\354\210\230\353\257\274/ex2.js" index 6b95f04..371b3b4 100644 --- "a/\354\235\264\354\210\230\353\257\274/ex2.js" +++ "b/\354\235\264\354\210\230\353\257\274/ex2.js" @@ -1,4 +1,62 @@ // range 함수를 작성하세요. -const range = (start, end, step = start > end ? -1 : 1) => { }; +const range = (start, end, step = start > end ? -1 : 1) => { + const ret = []; + // 1번 케이스: start만 있는 경우 (test case에는 정수만 있음) + if (end === undefined) { + // 1-1번 케이스: range(정수)일 때 + // 1-1-1번 케이스: range(양의 정수)일 때 + if (start > 0) { + for (i = 1; i <= start; i++) { + ret.push(i); + } + // 1-1-2번 케이스: range(음의 정수 or 0)일 때 + } else if (start < 0) { + for (i = start; i < 0; i++) { + ret.push(i); + } + // 1-1-3번 케이스: range(0)인 경우 + } else { + ret.push(0); + } + // 2번 케이스: start, end가 다 있는 경우 + } else { + // 2-1번 케이스: step이 0이거나 실수 0인 경우 + if (step === 0 || step - 0 === 1e-10) { + ret.push(start); + // 2-2번 케이스: step이 0이 아닌 경우 + } else { + // 2-2-1번 케이스: step의 값이 start -> end의 추세와 맞는 경우 + if (!((start < end && step < 0) || (start > end && step > 0))) { + // 2-2-1-1번 케이스: start -> end가 증가하는 경우 + if (start < end) { + if (Number.isInteger(step)) { + for (i = start; i <= end; i = i + step) { + ret.push(i); + } + } else { + for (i = start; i.toFixed(1) <= end; i = i + step) { + ret.push(parseFloat(i.toFixed(1))); + } + } + // 2-2-1-2번 케이스: start -> end가 감소하는 경우 + } else if (start > end) { + if (Number.isInteger(step)) { + for (i = start; i >= end; i = i + step) { + ret.push(i); + } + } else { + for (i = start; i.toFixed(1) >= end; i = i + step) { + ret.push(parseFloat(i.toFixed(1))); + } + } + // 2-2-1-3번 케이스: start === end인 경우 + } else { + ret.push(start); + } + } + } + } + return ret; +}; module.exports = { range }; diff --git "a/\354\235\264\354\210\230\353\257\274/ex2.test.js" "b/\354\235\264\354\210\230\353\257\274/ex2.test.js" index cbdb2e8..ec97ac7 100644 --- "a/\354\235\264\354\210\230\353\257\274/ex2.test.js" +++ "b/\354\235\264\354\210\230\353\257\274/ex2.test.js" @@ -1,5 +1,5 @@ -const assert = require('assert'); -const { range } = require('./ex2'); +const assert = require("assert"); +const { range } = require("./ex2"); assert.deepStrictEqual(range(1, 10, 1), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); assert.deepStrictEqual(range(1, 10, 2), [1, 3, 5, 7, 9]); diff --git "a/\354\235\264\354\210\230\353\257\274/ex3.test.js" "b/\354\235\264\354\210\230\353\257\274/ex3.test.js" index 6c27a4d..bc37804 100644 --- "a/\354\235\264\354\210\230\353\257\274/ex3.test.js" +++ "b/\354\235\264\354\210\230\353\257\274/ex3.test.js" @@ -8,11 +8,11 @@ const users = [lee, hong, kim]; assert.deepStrictEqual(users.sortBy('id'), [hong, kim, lee]); assert.deepStrictEqual(users.sortBy('name:desc'), [lee, kim, hong]); -assert.deepStrictEqual(users.sortBy('dept:desc,city:asc'), [hong, lee, kim]); +assert.deepStrictEqual(users.sortBy('dept:desc,city:asc'), [lee, kim, hong]); assert.deepStrictEqual(users.sortBy('dept:desc,city:desc'), [kim, lee, hong]); assert.deepStrictEqual(users.sortBy('name:desc,id:,dept:desc'), [ - kim, lee, + kim, hong, ]); -assert.deepStrictEqual(users.sortBy('dept:desc,id'), [hong, kim, lee]); +assert.deepStrictEqual(users.sortBy('dept:desc,id'), [kim, lee, hong]); \ No newline at end of file From 8c3c73056766dc7774e756163b8ea4573e2b1854 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=88=98=EB=AF=BC?= Date: Wed, 11 Sep 2024 15:23:43 +0900 Subject: [PATCH 04/16] ex3 (feat) completed --- "\354\235\264\354\210\230\353\257\274/ex3.js" | 22 +++++++++++++++-- .../ex3.test.js" | 24 +++++++++---------- 2 files changed, 32 insertions(+), 14 deletions(-) diff --git "a/\354\235\264\354\210\230\353\257\274/ex3.js" "b/\354\235\264\354\210\230\353\257\274/ex3.js" index b1b0d75..2b78f5b 100644 --- "a/\354\235\264\354\210\230\353\257\274/ex3.js" +++ "b/\354\235\264\354\210\230\353\257\274/ex3.js" @@ -1,3 +1,21 @@ -Array.prototype.sortBy = function (sortProp = '') { - return this; +Array.prototype.sortBy = function (sortProp = "") { + const sorter = sortProp.split(",").map((query) => { + const [key, orderBy = "asc"] = query.split(":"); + return { key, orderBy: orderBy.toLowerCase() }; + }); + // compareFunction: 기준 key에 따라 orderBy대로 a의 값이 b의 값보다 더 크면 1, 작으면 -1, b와 같으면 0 반환 + return this.slice().sort((a, b) => { + for (const { key, orderBy } of sorter) { + const value1 = a[key]; + const value2 = b[key]; + + if (value1 < value2) { + return orderBy === "asc" ? -1 : 1; + } + if (value1 > value2) { + return orderBy === "asc" ? 1 : -1; + } + } + return 0; + }); }; diff --git "a/\354\235\264\354\210\230\353\257\274/ex3.test.js" "b/\354\235\264\354\210\230\353\257\274/ex3.test.js" index 6c27a4d..2774d71 100644 --- "a/\354\235\264\354\210\230\353\257\274/ex3.test.js" +++ "b/\354\235\264\354\210\230\353\257\274/ex3.test.js" @@ -1,18 +1,18 @@ -const assert = require('assert'); -require('./ex3'); +const assert = require("assert"); +require("./ex3"); -const hong = { id: 1, name: 'Hong', city: 'Busan', dept: 1 }; -const kim = { id: 2, name: 'Kim', city: 'Seoul', dept: 2 }; -const lee = { id: 3, name: 'Lee', city: 'Daegu', dept: 2 }; +const hong = { id: 1, name: "Hong", city: "Busan", dept: 1 }; +const kim = { id: 2, name: "Kim", city: "Seoul", dept: 2 }; +const lee = { id: 3, name: "Lee", city: "Daegu", dept: 2 }; const users = [lee, hong, kim]; -assert.deepStrictEqual(users.sortBy('id'), [hong, kim, lee]); -assert.deepStrictEqual(users.sortBy('name:desc'), [lee, kim, hong]); -assert.deepStrictEqual(users.sortBy('dept:desc,city:asc'), [hong, lee, kim]); -assert.deepStrictEqual(users.sortBy('dept:desc,city:desc'), [kim, lee, hong]); -assert.deepStrictEqual(users.sortBy('name:desc,id:,dept:desc'), [ - kim, +assert.deepStrictEqual(users.sortBy("id"), [hong, kim, lee]); +assert.deepStrictEqual(users.sortBy("name:desc"), [lee, kim, hong]); +assert.deepStrictEqual(users.sortBy("dept:desc,city:asc"), [lee, kim, hong]); +assert.deepStrictEqual(users.sortBy("dept:desc,city:desc"), [kim, lee, hong]); +assert.deepStrictEqual(users.sortBy("name:desc,id:,dept:desc"), [ lee, + kim, hong, ]); -assert.deepStrictEqual(users.sortBy('dept:desc,id'), [hong, kim, lee]); +assert.deepStrictEqual(users.sortBy("dept:desc,id"), [kim, lee, hong]); From e7d6ed589a61c1ad6aa944e1f92971b18410057d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=88=98=EB=AF=BC?= Date: Wed, 11 Sep 2024 17:14:16 +0900 Subject: [PATCH 05/16] ex4 (feat) completed --- "\354\235\264\354\210\230\353\257\274/ex3.js" | 2 +- .../ex3.test.js" | 22 ++++---- "\354\235\264\354\210\230\353\257\274/ex4.js" | 56 ++++++++++++++++++- .../ex4.test.js" | 26 ++++----- 4 files changed, 80 insertions(+), 26 deletions(-) diff --git "a/\354\235\264\354\210\230\353\257\274/ex3.js" "b/\354\235\264\354\210\230\353\257\274/ex3.js" index 2b78f5b..106c784 100644 --- "a/\354\235\264\354\210\230\353\257\274/ex3.js" +++ "b/\354\235\264\354\210\230\353\257\274/ex3.js" @@ -3,7 +3,7 @@ Array.prototype.sortBy = function (sortProp = "") { const [key, orderBy = "asc"] = query.split(":"); return { key, orderBy: orderBy.toLowerCase() }; }); - // compareFunction: 기준 key에 따라 orderBy대로 a의 값이 b의 값보다 더 크면 1, 작으면 -1, b와 같으면 0 반환 + // sort의 compare function: 기준 key에 따라 orderBy대로 a의 값이 b의 값보다 더 크면 1, 작으면 -1, b와 같으면 0 반환 return this.slice().sort((a, b) => { for (const { key, orderBy } of sorter) { const value1 = a[key]; diff --git "a/\354\235\264\354\210\230\353\257\274/ex3.test.js" "b/\354\235\264\354\210\230\353\257\274/ex3.test.js" index bc37804..2774d71 100644 --- "a/\354\235\264\354\210\230\353\257\274/ex3.test.js" +++ "b/\354\235\264\354\210\230\353\257\274/ex3.test.js" @@ -1,18 +1,18 @@ -const assert = require('assert'); -require('./ex3'); +const assert = require("assert"); +require("./ex3"); -const hong = { id: 1, name: 'Hong', city: 'Busan', dept: 1 }; -const kim = { id: 2, name: 'Kim', city: 'Seoul', dept: 2 }; -const lee = { id: 3, name: 'Lee', city: 'Daegu', dept: 2 }; +const hong = { id: 1, name: "Hong", city: "Busan", dept: 1 }; +const kim = { id: 2, name: "Kim", city: "Seoul", dept: 2 }; +const lee = { id: 3, name: "Lee", city: "Daegu", dept: 2 }; const users = [lee, hong, kim]; -assert.deepStrictEqual(users.sortBy('id'), [hong, kim, lee]); -assert.deepStrictEqual(users.sortBy('name:desc'), [lee, kim, hong]); -assert.deepStrictEqual(users.sortBy('dept:desc,city:asc'), [lee, kim, hong]); -assert.deepStrictEqual(users.sortBy('dept:desc,city:desc'), [kim, lee, hong]); -assert.deepStrictEqual(users.sortBy('name:desc,id:,dept:desc'), [ +assert.deepStrictEqual(users.sortBy("id"), [hong, kim, lee]); +assert.deepStrictEqual(users.sortBy("name:desc"), [lee, kim, hong]); +assert.deepStrictEqual(users.sortBy("dept:desc,city:asc"), [lee, kim, hong]); +assert.deepStrictEqual(users.sortBy("dept:desc,city:desc"), [kim, lee, hong]); +assert.deepStrictEqual(users.sortBy("name:desc,id:,dept:desc"), [ lee, kim, hong, ]); -assert.deepStrictEqual(users.sortBy('dept:desc,id'), [kim, lee, hong]); \ No newline at end of file +assert.deepStrictEqual(users.sortBy("dept:desc,id"), [kim, lee, hong]); diff --git "a/\354\235\264\354\210\230\353\257\274/ex4.js" "b/\354\235\264\354\210\230\353\257\274/ex4.js" index 9ede02f..3fcc87e 100644 --- "a/\354\235\264\354\210\230\353\257\274/ex4.js" +++ "b/\354\235\264\354\210\230\353\257\274/ex4.js" @@ -1,3 +1,57 @@ -function deepCopy(obj) {} +function deepCopy(obj) { + // 0번 케이스: obj가 null이나 원시 타입인 경우 + if (obj === null || typeof obj !== "object") { + return obj; + } + + // 1번 케이스: obj가 배열인 경우 + if (Array.isArray(obj)) { + return obj.map((item) => deepCopy(item)); + } + + // 2번 케이스: obj가 Set인 경우 + if (obj instanceof Set) { + const copy = new Set(); + obj.forEach((value) => copy.add(deepCopy(value))); + return copy; + } + + // 3번 케이스: obj가 Map인 경우 + if (obj instanceof Map) { + // Map을 복사 + const copy = new Map(); + obj.forEach((value, key) => copy.set(deepCopy(key), deepCopy(value))); + return copy; + } + + // 4번 케이스: obj가 WeakSet인 경우 + if (obj instanceof WeakSet) { + // WeakSet은 복사할 수 없습니다 (WeakSet은 약한 참조만 저장) + return new WeakSet(); // 빈 WeakSet 반환 + } + + // 5번 케이스: obj가 WeakMap인 경우 + if (obj instanceof WeakMap) { + // WeakMap은 복사할 수 없습니다 (WeakMap은 약한 참조만 저장) + return new WeakMap(); // 빈 WeakMap 반환 + } + + // 6번 케이스: obj가 그냥 객체인 경우 + if (obj instanceof Object) { + const copy = {}; + Object.keys(obj).forEach((key) => { + // 심볼 속성도 복사 + const value = obj[key]; + copy[key] = deepCopy(value); + }); + + // obj의 심볼 속성도 복사 + const symbols = Object.getOwnPropertySymbols(obj); + symbols.forEach((symbol) => { + copy[symbol] = deepCopy(obj[symbol]); + }); + return copy; + } +} module.exports = { deepCopy }; diff --git "a/\354\235\264\354\210\230\353\257\274/ex4.test.js" "b/\354\235\264\354\210\230\353\257\274/ex4.test.js" index 2699ce8..d12f57d 100644 --- "a/\354\235\264\354\210\230\353\257\274/ex4.test.js" +++ "b/\354\235\264\354\210\230\353\257\274/ex4.test.js" @@ -1,14 +1,14 @@ -const assert = require('assert'); -const { deepCopy } = require('./ex4'); +const assert = require("assert"); +const { deepCopy } = require("./ex4"); const arr = [1, 2, 3]; -const hong = { id: 1, name: 'Hong', city: 'Busan', dept: 1 }; +const hong = { id: 1, name: "Hong", city: "Busan", dept: 1 }; const kim = { nid: 3, - addr: 'Pusan', + addr: "Pusan", arr: [1, 2, 3, { aid: 1 }, [10, 20]], - oo: { id: 1, name: 'Hong', addr: { city: 'Seoul' } }, + oo: { id: 1, name: "Hong", addr: { city: "Seoul" } }, xx: null, yy: function () { console.log(this.oo); @@ -17,24 +17,24 @@ const kim = { console.log(this.oo); }, [Symbol()]: 9, - [Symbol()]: Symbol('symbol2'), + [Symbol()]: Symbol("symbol2"), zs: new Set([arr, hong]), zws: new WeakSet([arr, hong]), zm: new Map([[hong, arr]]), zwm: new WeakMap([[hong, arr]]), }; const newKim = deepCopy(kim); -assert.deepStrictEqual(newKim, kim, 'deepCopy equal fail!'); -newKim.addr = 'Daegu'; -newKim.oo.name = 'Kim'; -assert.notDeepStrictEqual(newKim, kim, 'Not Valid Deep Copy!'); +assert.deepStrictEqual(newKim, kim, "deepCopy equal fail!"); +newKim.addr = "Daegu"; +newKim.oo.name = "Kim"; +assert.notDeepStrictEqual(newKim, kim, "Not Valid Deep Copy!"); newKim.arr[0] = 100; newKim.arr[3].aid = 200; newKim.arr[4][1] = 300; -newKim.oo.addr.city = 'Daejeon'; -assert.notStrictEqual(kim.arr[4][1], newKim.arr[4][1], 'pass2: 다르지 않아요!'); +newKim.oo.addr.city = "Daejeon"; +assert.notStrictEqual(kim.arr[4][1], newKim.arr[4][1], "pass2: 다르지 않아요!"); assert.notStrictEqual( kim.oo.addr.city, newKim.oo.addr.city, - 'Not Pass3: city가 다르지 않아요!' + "Not Pass3: city가 다르지 않아요!" ); From e932c1f6e36f971e37297bec605363ed7a8679f1 Mon Sep 17 00:00:00 2001 From: suminjeff Date: Thu, 12 Sep 2024 10:25:11 +0900 Subject: [PATCH 06/16] ex5 (feat) completed --- "\354\235\264\354\210\230\353\257\274/ex5.js" | 35 ++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git "a/\354\235\264\354\210\230\353\257\274/ex5.js" "b/\354\235\264\354\210\230\353\257\274/ex5.js" index 464a05a..46be508 100644 --- "a/\354\235\264\354\210\230\353\257\274/ex5.js" +++ "b/\354\235\264\354\210\230\353\257\274/ex5.js" @@ -1,3 +1,36 @@ module.exports = { - searchByKoreanInitialSound: (data, firstSounds) => {}, + searchByKoreanInitialSound: (data, firstSounds) => { + const koreanInitials = "ㄱㄲㄴㄷㄸㄹㅁㅂㅃㅅㅆㅇㅈㅉㅊㅋㅌㅍㅎ".split(""); + const startCode = "가".charCodeAt(); + const endCode = "힣".charCodeAt(); + + // 초성을 찾아주는 함수 + function getKoreanInitials(character) { + const code = character.charCodeAt(); + // 44032: 가, 55203: 힣 + if (code >= startCode && code <= endCode) { + const index = Math.floor((code - startCode) / (21 * 28)); + return koreanInitials[index]; + } + return character; + } + + // 정규식 생성 + const regex = new RegExp( + firstSounds + .split("") + .map((e) => { + if (koreanInitials.includes(e)) { + return `[${e}]`; + } + return e; + }) + .join(".*") + ); + + return data.filter((item) => { + const initials = Array.from(item).map(getKoreanInitials).join(""); + return regex.test(initials); + }); + }, }; From 81e95a7472a70480eaeb214873286d2fc69b89ae Mon Sep 17 00:00:00 2001 From: suminjeff Date: Thu, 12 Sep 2024 17:18:57 +0900 Subject: [PATCH 07/16] ex1 (feat) book-edit & index completed --- .../ex1/book-edit.html" | 81 ++++- .../ex1/index.html" | 176 ++++++++- .../ex1/output.css" | 344 +++++++++++++++++- .../ex1/register.html" | 2 +- .../ex1/static/bookmark.svg" | 2 +- .../ex1/static/indiflex.jpg" | Bin 0 -> 35049 bytes .../ex1/static/kakao.png" | Bin 0 -> 11410 bytes .../ex1/static/line.svg" | 1 + .../ex1/static/naver.png" | Bin 0 -> 4911 bytes .../ex1/static/nextjs.png" | Bin 0 -> 10702 bytes .../ex1/static/reload.svg" | 18 + .../ex1/static/save.svg" | 4 + .../ex1/static/settings.svg" | 2 + .../ex1/static/tailwind.png" | Bin 0 -> 3405 bytes .../ex1/static/youtube.png" | Bin 0 -> 6990 bytes 15 files changed, 598 insertions(+), 32 deletions(-) rename "\354\235\264\354\210\230\353\257\274/ex1/static/bookmark_logo.svg" => "\354\235\264\354\210\230\353\257\274/ex1/static/bookmark.svg" (71%) create mode 100644 "\354\235\264\354\210\230\353\257\274/ex1/static/indiflex.jpg" create mode 100644 "\354\235\264\354\210\230\353\257\274/ex1/static/kakao.png" create mode 100644 "\354\235\264\354\210\230\353\257\274/ex1/static/line.svg" create mode 100644 "\354\235\264\354\210\230\353\257\274/ex1/static/naver.png" create mode 100644 "\354\235\264\354\210\230\353\257\274/ex1/static/nextjs.png" create mode 100644 "\354\235\264\354\210\230\353\257\274/ex1/static/reload.svg" create mode 100644 "\354\235\264\354\210\230\353\257\274/ex1/static/save.svg" create mode 100644 "\354\235\264\354\210\230\353\257\274/ex1/static/settings.svg" create mode 100644 "\354\235\264\354\210\230\353\257\274/ex1/static/tailwind.png" create mode 100644 "\354\235\264\354\210\230\353\257\274/ex1/static/youtube.png" diff --git "a/\354\235\264\354\210\230\353\257\274/ex1/book-edit.html" "b/\354\235\264\354\210\230\353\257\274/ex1/book-edit.html" index 76e3f1e..4ab9079 100644 --- "a/\354\235\264\354\210\230\353\257\274/ex1/book-edit.html" +++ "b/\354\235\264\354\210\230\353\257\274/ex1/book-edit.html" @@ -3,10 +3,16 @@ - Document + BookMark + - +