From 49a867dd377523dbc745302dfb41139579093dad Mon Sep 17 00:00:00 2001 From: Amruth Pillai Date: Sun, 5 Jul 2020 16:45:29 +0530 Subject: [PATCH] - recreating onyx template - profile section complete --- src/components/builder/center/Artboard.js | 17 ++--- .../builder/center/Artboard.module.css | 5 +- src/components/builder/sections/Layout.js | 18 ++--- .../builder/sections/Layout.module.css | 8 +-- src/components/builder/sections/Profile.js | 22 +++++- .../builder/sections/Profile.module.css | 2 +- src/components/dashboard/CreateResume.js | 4 +- .../dashboard/CreateResume.module.css | 8 +-- src/components/shared/Input.module.css | 4 +- src/contexts/ResumeContext.js | 5 ++ src/contexts/TemplateContext.js | 33 ++++++--- src/contexts/ThemeContext.js | 2 + src/pages/app/builder.js | 2 +- src/styles/colors.css | 5 +- src/styles/global.css | 8 +++ src/templates/Onyx.js | 68 +++++++++++++++++++ tailwind.config.js | 1 + 17 files changed, 159 insertions(+), 53 deletions(-) create mode 100644 src/templates/Onyx.js diff --git a/src/components/builder/center/Artboard.js b/src/components/builder/center/Artboard.js index de0ebee2..937b4806 100644 --- a/src/components/builder/center/Artboard.js +++ b/src/components/builder/center/Artboard.js @@ -1,21 +1,16 @@ import React, { useContext } from "react"; +import ResumeContext from "../../../contexts/ResumeContext"; import TemplateContext from "../../../contexts/TemplateContext"; +import Onyx from "../../../templates/Onyx"; import styles from "./Artboard.module.css"; const Artboard = () => { - const { blocks } = useContext(TemplateContext); + const { blocks, colors } = useContext(TemplateContext); + const { state } = useContext(ResumeContext); return ( -
-
- {blocks.map((block, ind) => ( -
- {block.map((x) => ( -
{x.name}
- ))} -
- ))} -
+
+
); }; diff --git a/src/components/builder/center/Artboard.module.css b/src/components/builder/center/Artboard.module.css index 30fbacee..2301c597 100644 --- a/src/components/builder/center/Artboard.module.css +++ b/src/components/builder/center/Artboard.module.css @@ -1,6 +1,7 @@ .container { - width: 400px; - height: 600px; + width: 210mm; + height: 297mm; + zoom: 0.8; box-shadow: var(--shadow); @apply bg-white; } diff --git a/src/components/builder/sections/Layout.js b/src/components/builder/sections/Layout.js index 86522975..3fb9fd69 100644 --- a/src/components/builder/sections/Layout.js +++ b/src/components/builder/sections/Layout.js @@ -1,4 +1,3 @@ -import cx from "classnames"; import React, { useContext } from "react"; import { DragDropContext, Draggable, Droppable } from "react-beautiful-dnd"; import TemplateContext from "../../../contexts/TemplateContext"; @@ -21,21 +20,18 @@ const Layout = () => { {blocks.map((el, ind) => ( - {(provided, snapshot) => ( + {(provided) => (
+ + Block {ind + 1} + {el.map((item, index) => ( - + {(provided) => (
{ {...provided.draggableProps} {...provided.dragHandleProps} > - {item.name} + {item}
)}
diff --git a/src/components/builder/sections/Layout.module.css b/src/components/builder/sections/Layout.module.css index b7bf2f87..a6a55734 100644 --- a/src/components/builder/sections/Layout.module.css +++ b/src/components/builder/sections/Layout.module.css @@ -1,11 +1,7 @@ .droppable { - @apply px-4 py-6 bg-gray-100 col-span-1 rounded; -} - -.droppable.dragging-over { - @apply bg-gray-200; + @apply p-6 bg-secondary-light col-span-1 rounded; } .draggable { - @apply px-4 py-2 font-medium rounded bg-gray-300; + @apply px-4 py-2 capitalize font-medium rounded bg-secondary; } diff --git a/src/components/builder/sections/Profile.js b/src/components/builder/sections/Profile.js index e4326376..c3333b5c 100644 --- a/src/components/builder/sections/Profile.js +++ b/src/components/builder/sections/Profile.js @@ -10,16 +10,34 @@ const Profile = () => { Profile
- +
-
+
+ + + +
+ + + + +
+ + +
+ +
+ + + + ); }; diff --git a/src/components/builder/sections/Profile.module.css b/src/components/builder/sections/Profile.module.css index c9346816..d2ac4b0c 100644 --- a/src/components/builder/sections/Profile.module.css +++ b/src/components/builder/sections/Profile.module.css @@ -2,5 +2,5 @@ width: 60px; height: 60px; flex: 0 0 60px; - @apply flex items-center justify-center bg-secondary rounded-full; + @apply flex items-center justify-center bg-secondary text-secondary-dark rounded-full; } diff --git a/src/components/dashboard/CreateResume.js b/src/components/dashboard/CreateResume.js index ff8d3572..683fd815 100644 --- a/src/components/dashboard/CreateResume.js +++ b/src/components/dashboard/CreateResume.js @@ -13,7 +13,7 @@ const CreateResume = () => { return (
- +
{ onClick={handleClick} onKeyDown={() => {}} > - +

Create New Resume

diff --git a/src/components/dashboard/CreateResume.module.css b/src/components/dashboard/CreateResume.module.css index 59104ed0..83028b81 100644 --- a/src/components/dashboard/CreateResume.module.css +++ b/src/components/dashboard/CreateResume.module.css @@ -5,16 +5,16 @@ .resume > .backdrop { max-width: 184px; height: 260px; - @apply rounded absolute w-full bg-black shadow; - @apply absolute text-gray-500 flex justify-center items-center; + @apply rounded absolute w-full bg-black text-white shadow; + @apply absolute flex justify-center items-center; } .resume > .page { max-width: 184px; height: 260px; - @apply rounded absolute w-full bg-inverse; + @apply rounded absolute w-full bg-secondary-light; @apply transition-opacity duration-200 ease-in-out; - @apply cursor-pointer absolute text-gray-500 flex justify-center items-center; + @apply cursor-pointer absolute flex justify-center items-center; } .resume > .page:hover { diff --git a/src/components/shared/Input.module.css b/src/components/shared/Input.module.css index e0f65f55..9b6370f7 100644 --- a/src/components/shared/Input.module.css +++ b/src/components/shared/Input.module.css @@ -7,7 +7,7 @@ } .container > label > span { - @apply mb-1 text-secondary-dark font-medium text-xs uppercase; + @apply mb-1 text-secondary-dark font-semibold tracking-wide text-xs uppercase; } .container > label > input { @@ -19,7 +19,7 @@ } .container > label > input:focus { - @apply outline-none border-secondary-dark; + @apply outline-none border-gray-500; } .container > label > p { diff --git a/src/contexts/ResumeContext.js b/src/contexts/ResumeContext.js index e3523986..1eba4901 100644 --- a/src/contexts/ResumeContext.js +++ b/src/contexts/ResumeContext.js @@ -2,11 +2,14 @@ import { set } from "lodash"; import React, { createContext, useReducer } from "react"; const initialState = { + id: "dafa3242-f39a-4755-bab3-be3c3ca3d190", profile: { photograph: "", firstName: "", lastName: "", }, + createdAt: "", + updatedAt: "", }; const ResumeContext = createContext(initialState); @@ -16,6 +19,8 @@ const ResumeProvider = ({ children }) => { switch (type) { case "on_input": return set({ ...state }, payload.path, payload.value); + case "set_data": + return payload; default: throw new Error(); } diff --git a/src/contexts/TemplateContext.js b/src/contexts/TemplateContext.js index addcff56..3793ca73 100644 --- a/src/contexts/TemplateContext.js +++ b/src/contexts/TemplateContext.js @@ -1,18 +1,17 @@ +import { flatten } from "lodash"; import React, { createContext, useState } from "react"; const defaultState = { selected: "Pikachu", setSelected: () => {}, + colors: { + textColor: "#212121", + primaryColor: "#f44336", + backgroundColor: "#FFFFFF", + }, blocks: [ - [ - { id: "1", name: "Profile" }, - { id: "2", name: "Work" }, - ], - [ - { id: "3", name: "Education" }, - { id: "4", name: "Skills" }, - { id: "5", name: "Hobbies" }, - ], + ["profile", "work"], + ["education", "skills", "hobbies"], ], setBlocks: () => {}, }; @@ -21,6 +20,7 @@ const TemplateContext = createContext(defaultState); const TemplateProvider = ({ children }) => { const [selected, setSelected] = useState(defaultState.selected); + const [colors, setColors] = useState(defaultState.colors); const [blocks, setBlocks] = useState(defaultState.blocks); const reorder = (list, startIndex, endIndex) => { @@ -68,13 +68,28 @@ const TemplateProvider = ({ children }) => { } }; + const setSupportedBlocks = (number) => { + if (number === blocks.length) return; + + if (number > blocks.length) { + setBlocks([...blocks, []]); + } + + if (number < blocks.length) { + setBlocks([flatten(blocks)]); + } + }; + return ( diff --git a/src/contexts/ThemeContext.js b/src/contexts/ThemeContext.js index 15efeb72..89556a16 100644 --- a/src/contexts/ThemeContext.js +++ b/src/contexts/ThemeContext.js @@ -6,6 +6,7 @@ const COLOR_CONFIG = { "--color-primary-dark": "#333", "--color-inverse": "#fff", "--color-inverse-dark": "#f5f5f5", + "--color-secondary-light": "#f7fafc", "--color-secondary": "#edf2f7", "--color-secondary-dark": "#718096", }, @@ -14,6 +15,7 @@ const COLOR_CONFIG = { "--color-primary-dark": "#eeeeee", "--color-inverse": "#212121", "--color-inverse-dark": "#181818", + "--color-secondary-light": "#2c2c2c", "--color-secondary": "#444", "--color-secondary-dark": "#888", }, diff --git a/src/pages/app/builder.js b/src/pages/app/builder.js index 2bd4a355..53e489a1 100644 --- a/src/pages/app/builder.js +++ b/src/pages/app/builder.js @@ -11,7 +11,7 @@ const Builder = ({ id }) => {
-
+
diff --git a/src/styles/colors.css b/src/styles/colors.css index c6a86344..4a404383 100644 --- a/src/styles/colors.css +++ b/src/styles/colors.css @@ -3,6 +3,7 @@ --color-primary-dark: #333; --color-inverse: #fff; --color-inverse-dark: #f5f5f5; - --color-secondary: #edf2f7; - --color-secondary-dark: #718096; + --color-secondary-light: #f7fafc; + --color-secondary: #e2e8f0; + --color-secondary-dark: #a0aec0; } diff --git a/src/styles/global.css b/src/styles/global.css index 4ee1e7ff..f6ac56d8 100644 --- a/src/styles/global.css +++ b/src/styles/global.css @@ -30,3 +30,11 @@ hr { section { @apply grid grid-cols-1 gap-8; } + +#artboard { + color: #444; +} + +#artboard hr { + border-color: #eee; +} diff --git a/src/templates/Onyx.js b/src/templates/Onyx.js new file mode 100644 index 00000000..9379731a --- /dev/null +++ b/src/templates/Onyx.js @@ -0,0 +1,68 @@ +import React, { useContext, useEffect } from "react"; +import { FaGlobeAmericas, FaPhone } from "react-icons/fa"; +import { MdEmail } from "react-icons/md"; +import TemplateContext from "../contexts/TemplateContext"; + +const Onyx = ({ data, layout, colors }) => { + const { setSelected, setSupportedBlocks } = useContext(TemplateContext); + + useEffect(() => { + setSelected("Onyx"); + setSupportedBlocks(1); + }, [setSelected, setSupportedBlocks]); + + return ( +
+ Photograph +
+

+ Nancy Jackson +

+ Customer Sales Representative + +
+ 3879 Gateway Avenue, + Bakersfield, + California, USA +
+
+
+
+ + +1 661-808-4188 +
+ +
+ + nancyontheweb.com +
+ +
+ + + nancyjack43@gmail.com + +
+
+ +
+ + {JSON.stringify(layout)} +
+ ); +}; + +export default Onyx; diff --git a/tailwind.config.js b/tailwind.config.js index 811e7a0d..9c205803 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -10,6 +10,7 @@ module.exports = { "primary-dark": "var(--color-primary-dark)", inverse: "var(--color-inverse)", "inverse-dark": "var(--color-inverse-dark)", + "secondary-light": "var(--color-secondary-light)", secondary: "var(--color-secondary)", "secondary-dark": "var(--color-secondary-dark)", },