From ddb4bb22e81016f21f8888ffc6e49479db0feace Mon Sep 17 00:00:00 2001 From: Zeeshan Ahmad Date: Wed, 3 Jan 2024 21:53:34 +0500 Subject: [PATCH 01/34] Create button component --- apps/builddao/widget/components/button.jsx | 63 +++++++++++++++++++++ apps/builddao/widget/components/library.jsx | 33 +++++++++++ 2 files changed, 96 insertions(+) create mode 100644 apps/builddao/widget/components/button.jsx create mode 100644 apps/builddao/widget/components/library.jsx diff --git a/apps/builddao/widget/components/button.jsx b/apps/builddao/widget/components/button.jsx new file mode 100644 index 00000000..689bbbf3 --- /dev/null +++ b/apps/builddao/widget/components/button.jsx @@ -0,0 +1,63 @@ +const StyledButton = styled.button` + all: unset; + display: inline-flex; + padding: 10px 20px; + justify-content: center; + align-items: center; + gap: 4px; + border-radius: 8px; + font: 500 14px / normal; + + ${(props) => + props.type === "icon" && + ` + display: flex; + width: 40px; + height: 40px; + padding: 5px; + flex-shrink: 0; + border-radius: 50%; + `} + + /* Colors based on variant prop */ + background: ${(props) => { + switch (props.variant) { + case "primary": + return "#FFAF51"; + case "outline": + return "#0b0c14"; + default: + return "#23242B"; + } + }}; + + color: ${(props) => { + switch (props.variant) { + case "primary": + return "#000"; + case "outline": + return "#fff"; + default: + return "#CDD0D5"; + } + }}; + + border: ${(props) => + props.variant === "outline" ? "1px solid rgba(255, 255, 255, 0.20)" : ""}; +`; + +function Button({ id, children, variant, type, className, style }) { + return ( + + {children} + + ); +} + +return { Button }; diff --git a/apps/builddao/widget/components/library.jsx b/apps/builddao/widget/components/library.jsx new file mode 100644 index 00000000..ec4244a3 --- /dev/null +++ b/apps/builddao/widget/components/library.jsx @@ -0,0 +1,33 @@ +const { Button } = VM.require("buildhub.near/widget/components.button"); + +return ( +
+
+ + + +
+
+ + + +
+
+ + + +
+
+); From b746d005aa37a4ad1a404033220bd449af4d7466 Mon Sep 17 00:00:00 2001 From: Zeeshan Ahmad Date: Wed, 3 Jan 2024 23:01:24 +0500 Subject: [PATCH 02/34] Add Pagination and Progress State component --- apps/builddao/widget/components/library.jsx | 80 ++++++++++------ .../widget/components/pagination-widget.jsx | 95 +++++++++++++++++++ .../builddao/widget/components/pagination.jsx | 20 ++++ .../widget/components/progress-state.jsx | 55 +++++++++++ 4 files changed, 223 insertions(+), 27 deletions(-) create mode 100644 apps/builddao/widget/components/pagination-widget.jsx create mode 100644 apps/builddao/widget/components/pagination.jsx create mode 100644 apps/builddao/widget/components/progress-state.jsx diff --git a/apps/builddao/widget/components/library.jsx b/apps/builddao/widget/components/library.jsx index ec4244a3..4d43e5b7 100644 --- a/apps/builddao/widget/components/library.jsx +++ b/apps/builddao/widget/components/library.jsx @@ -1,33 +1,59 @@ const { Button } = VM.require("buildhub.near/widget/components.button"); +const { Pagination } = VM.require("buildhub.near/widget/components.pagination"); +const { ProgressState } = VM.require( + "buildhub.near/widget/components.progress-state" +); + +const Heading = styled.h2` + color: white; +`; return ( -
-
- - - -
-
- - - -
-
- - - +
+
+ Buttons +
+ + + +
+
+ + + +
+
+ + + +
+
+ Pagination + +
+
+ Progress State +
+ 1 + 1 + + + + 1 +
+
); diff --git a/apps/builddao/widget/components/pagination-widget.jsx b/apps/builddao/widget/components/pagination-widget.jsx new file mode 100644 index 00000000..56544bce --- /dev/null +++ b/apps/builddao/widget/components/pagination-widget.jsx @@ -0,0 +1,95 @@ +const totalPages = props.totalPages ?? 12; // Assume you have 12 pages +const maxVisiblePages = props.maxVisiblePages ?? 4; +const onPageClick = props.onPageClick + ? props.onPageClick + : () => console.log("clicked"); +const pagesToShow = Math.min(totalPages, maxVisiblePages); +const [selectedPage, setSelectedPage] = useState(props.selectedPage ?? 11); +const totalPageSets = Math.ceil(totalPages / maxVisiblePages); +const [currentPageSet, setCurrentPageSet] = useState(totalPageSets); + +const Pagination = styled.div` + display: flex; + gap: 12px; + + div { + display: flex; + height: 40px; + min-width: 40px; + padding: 12px; + justify-content: center; + align-items: center; + gap: 10px; + border-radius: 8px; + color: var(--White-100, #fff); + transition: all 300ms; + cursor: pointer; + + /* Other/Button_text */ + font-size: 14px; + font-style: normal; + font-weight: 500; + line-height: normal; + + &.selected, + &:hover { + background-color: #23242b; + } + + &.arrow { + border: 1px solid rgba(255, 255, 255, 0.2); + } + + &.disabled { + cursor: not-allowed; + } + } +`; + +const handlePageClick = (pageNumber) => { + onPageClick(pageNumber); +}; + +const handleArrowClick = (direction) => { + if (direction === "left") { + setCurrentPageSet(Math.max(currentPageSet - 1, 1)); + } else { + setCurrentPageSet( + Math.min(currentPageSet + 1, Math.ceil(totalPages / maxVisiblePages)) + ); + } +}; + +const getPageNumber = (index) => + (currentPageSet - 1) * maxVisiblePages + index + 1; + +return ( + +
handleArrowClick("left")} + > + +
+ {Array.from({ length: pagesToShow }).map((_, index) => { + const pageNumber = getPageNumber(index); + return ( +
handlePageClick(pageNumber)} + > + {pageNumber} +
+ ); + })} +
handleArrowClick("right")} + > + +
+
+); diff --git a/apps/builddao/widget/components/pagination.jsx b/apps/builddao/widget/components/pagination.jsx new file mode 100644 index 00000000..f371a359 --- /dev/null +++ b/apps/builddao/widget/components/pagination.jsx @@ -0,0 +1,20 @@ +function Pagination({ + totalPages, + maxVisiblePages, + onPageClick, + selectedPage, +}) { + return ( + + ); +} + +return { Pagination }; diff --git a/apps/builddao/widget/components/progress-state.jsx b/apps/builddao/widget/components/progress-state.jsx new file mode 100644 index 00000000..dfa4e6c2 --- /dev/null +++ b/apps/builddao/widget/components/progress-state.jsx @@ -0,0 +1,55 @@ +const Progress = styled.div` + display: flex; + width: 40px; + height: 40px; + padding: 12px; + justify-content: center; + align-items: center; + gap: 10px; + + border-radius: 50%; + border: ${(props) => { + switch (props.status) { + case "focused": + return "1px solid var(--Yellow, #FFAF51)"; + case "error": + return "1px solid var(--System-Red, #FD2A5C)"; + case "completed": + return "1px solid var(--Stroke-color, rgba(255, 255, 255, 0.20))"; + default: + return "1px solid var(--Stroke-color, rgba(255, 255, 255, 0.20))"; + } + }}; + + background: ${(props) => { + switch (props.status) { + case "focused": + return "rgba(255, 189, 52, 0.15)"; + case "error": + return "rgba(253, 42, 92, 0.15)"; + case "completed": + return "#FFAF51"; + default: + return "#23242B"; + } + }}; + + color: ${(props) => { + switch (props.status) { + case "focused": + return "#fff"; + case "error": + return "#FD2A5C"; + case "completed": + return "#000"; + default: + return "#fff"; + } + }}; +`; + +function ProgressState({ children, status }) { + return {children}; +} + +return { ProgressState }; From d516f6a48bef53d1807a0a763330dafc8adf313f Mon Sep 17 00:00:00 2001 From: Zeeshan Ahmad Date: Wed, 3 Jan 2024 23:24:43 +0500 Subject: [PATCH 03/34] Add progress state and step components --- apps/builddao/widget/components/library.jsx | 13 +++-- .../widget/components/progress-state.jsx | 16 ++++-- apps/builddao/widget/components/step.jsx | 53 +++++++++++++++++++ 3 files changed, 76 insertions(+), 6 deletions(-) create mode 100644 apps/builddao/widget/components/step.jsx diff --git a/apps/builddao/widget/components/library.jsx b/apps/builddao/widget/components/library.jsx index 4d43e5b7..e486f173 100644 --- a/apps/builddao/widget/components/library.jsx +++ b/apps/builddao/widget/components/library.jsx @@ -3,6 +3,7 @@ const { Pagination } = VM.require("buildhub.near/widget/components.pagination"); const { ProgressState } = VM.require( "buildhub.near/widget/components.progress-state" ); +const { Step } = VM.require("buildhub.near/widget/components.step"); const Heading = styled.h2` color: white; @@ -48,12 +49,18 @@ return (
1 1 - - - + 1 1
+
+ Step +
+ + + +
+
); diff --git a/apps/builddao/widget/components/progress-state.jsx b/apps/builddao/widget/components/progress-state.jsx index dfa4e6c2..91d83948 100644 --- a/apps/builddao/widget/components/progress-state.jsx +++ b/apps/builddao/widget/components/progress-state.jsx @@ -24,9 +24,9 @@ const Progress = styled.div` background: ${(props) => { switch (props.status) { case "focused": - return "rgba(255, 189, 52, 0.15)"; + return "#2f2619"; case "error": - return "rgba(253, 42, 92, 0.15)"; + return "#2f101f"; case "completed": return "#FFAF51"; default: @@ -49,7 +49,17 @@ const Progress = styled.div` `; function ProgressState({ children, status }) { - return {children}; + return ( + + {status === "completed" ? ( + + ) : status === "error" ? ( + + ) : ( + children + )} + + ); } return { ProgressState }; diff --git a/apps/builddao/widget/components/step.jsx b/apps/builddao/widget/components/step.jsx new file mode 100644 index 00000000..d9cb48ba --- /dev/null +++ b/apps/builddao/widget/components/step.jsx @@ -0,0 +1,53 @@ +const { ProgressState } = VM.require( + "buildhub.near/widget/components.progress-state" +); + +function Step(props) { + const totalSteps = props.totalSteps ?? 5; + const currentStep = props.currentStep ?? 3; + const currentStatus = props.currentStatus ? props.currentStatus : "focused"; + + const Container = styled.div` + position: relative; + + &::before { + content: ""; + position: absolute; + top: 50%; + left: 0; + right: 0; + height: 1px; + background: #000; /* Change color as needed */ + background-image: repeating-linear-gradient( + 90deg, + #3c3d43, + #3c3d43 2px, + transparent 2px, + transparent 4px + ); + transform: translateY(-50%); + z-index: -1; + } + `; + + return ( + + {Array.from({ length: totalSteps }).map((_, i) => ( + i + 1 + ? "completed" + : "default" + } + > + {i + 1} + + ))} + + ); +} + +return { Step }; From b9737b578377a46e1faaa8de9262b7648fc53d39 Mon Sep 17 00:00:00 2001 From: Zeeshan Ahmad Date: Thu, 4 Jan 2024 00:16:47 +0500 Subject: [PATCH 04/34] Add Input Field and Password Field --- .../widget/components/input-field-widget.jsx | 84 +++++++++++++++++++ .../widget/components/input-field.jsx | 17 ++++ apps/builddao/widget/components/library.jsx | 26 ++++++ .../widget/components/password-field.jsx | 17 ++++ apps/builddao/widget/components/step.jsx | 5 +- 5 files changed, 148 insertions(+), 1 deletion(-) create mode 100644 apps/builddao/widget/components/input-field-widget.jsx create mode 100644 apps/builddao/widget/components/input-field.jsx create mode 100644 apps/builddao/widget/components/password-field.jsx diff --git a/apps/builddao/widget/components/input-field-widget.jsx b/apps/builddao/widget/components/input-field-widget.jsx new file mode 100644 index 00000000..79e93fdf --- /dev/null +++ b/apps/builddao/widget/components/input-field-widget.jsx @@ -0,0 +1,84 @@ +const value = props.value; +const onChange = props.onChange; +const label = props.label; +const type = props.type; +const placeholder = props.placeholder; +const maxWidth = props.maxWidth ?? "390px"; +const [showPassword, setShowPassword] = useState(false); + +const Container = styled.div` + display: inline-flex; + flex-direction: column; + align-items: flex-start; + gap: 4px; +`; + +const Label = styled.label` + color: var(--White-100, #fff); + + /* Body/16px */ + font-size: 16px; + font-style: normal; + font-weight: 400; + line-height: 170%; /* 27.2px */ +`; + +const Input = styled.input` + display: flex; + max-width: ${maxWidth}; + width: 100%; + padding: 16px 12px; + align-items: flex-start; + gap: 10px; + + border-radius: 8px; + border: 1px solid var(--Stroke-color, rgba(255, 255, 255, 0.2)); + background: var(--Bg-1, #0b0c14); + + flex: 1 0 0; + + color: var(--White-50, #cdd0d5); + + /* Body/16px */ + font-size: 16px; + font-style: normal; + font-weight: 400; + line-height: 170%; /* 27.2px */ +`; + +return ( + + +
+ + {type === "password" && ( + setShowPassword(!showPassword)} + > + {showPassword ? ( + + ) : ( + + )} + + )} +
+
+); diff --git a/apps/builddao/widget/components/input-field.jsx b/apps/builddao/widget/components/input-field.jsx new file mode 100644 index 00000000..cf66c323 --- /dev/null +++ b/apps/builddao/widget/components/input-field.jsx @@ -0,0 +1,17 @@ +function InputField({ value, onChange, label, type, placeholder, maxWidth }) { + return ( + + ); +} + +return { InputField }; diff --git a/apps/builddao/widget/components/library.jsx b/apps/builddao/widget/components/library.jsx index e486f173..26e12c46 100644 --- a/apps/builddao/widget/components/library.jsx +++ b/apps/builddao/widget/components/library.jsx @@ -4,11 +4,20 @@ const { ProgressState } = VM.require( "buildhub.near/widget/components.progress-state" ); const { Step } = VM.require("buildhub.near/widget/components.step"); +const { InputField } = VM.require( + "buildhub.near/widget/components.input-field" +); +const { PasswordField } = VM.require( + "buildhub.near/widget/components.password-field" +); const Heading = styled.h2` color: white; `; +const [value, setValue] = useState(""); +const [password, setPassword] = useState(""); + return (
@@ -61,6 +70,23 @@ return (
+
+ Input Field +
+ setValue(e.target.value)} + placeholder={"Placeholder"} + /> + setPassword(e.target.value)} + placeholder={"Password"} + /> +
+
); diff --git a/apps/builddao/widget/components/password-field.jsx b/apps/builddao/widget/components/password-field.jsx new file mode 100644 index 00000000..e966074a --- /dev/null +++ b/apps/builddao/widget/components/password-field.jsx @@ -0,0 +1,17 @@ +function PasswordField({ value, onChange, label, placeholder, maxWidth }) { + return ( + + ); +} + +return { PasswordField }; diff --git a/apps/builddao/widget/components/step.jsx b/apps/builddao/widget/components/step.jsx index d9cb48ba..5b273810 100644 --- a/apps/builddao/widget/components/step.jsx +++ b/apps/builddao/widget/components/step.jsx @@ -31,7 +31,10 @@ function Step(props) { `; return ( - + {Array.from({ length: totalSteps }).map((_, i) => ( Date: Thu, 4 Jan 2024 00:45:25 +0500 Subject: [PATCH 05/34] Add checkbox --- apps/builddao/widget/components/checkbox.jsx | 34 ++++++++++++++++++++ apps/builddao/widget/components/library.jsx | 7 ++++ 2 files changed, 41 insertions(+) create mode 100644 apps/builddao/widget/components/checkbox.jsx diff --git a/apps/builddao/widget/components/checkbox.jsx b/apps/builddao/widget/components/checkbox.jsx new file mode 100644 index 00000000..fd2569d2 --- /dev/null +++ b/apps/builddao/widget/components/checkbox.jsx @@ -0,0 +1,34 @@ +const Input = styled.input` + display: none; +`; + +const Label = styled.label` + display: inline-flex; + padding: 12px; + align-items: center; + gap: 8px; + + color: #fff; + font-size: 16px; + font-style: normal; + font-weight: 400; + line-height: 170%; /* 27.2px */ +`; + +function Checkbox({ value, onChange, label }) { + return ( +
+ +
+ ); +} + +return { Checkbox }; diff --git a/apps/builddao/widget/components/library.jsx b/apps/builddao/widget/components/library.jsx index 26e12c46..84ced475 100644 --- a/apps/builddao/widget/components/library.jsx +++ b/apps/builddao/widget/components/library.jsx @@ -10,6 +10,7 @@ const { InputField } = VM.require( const { PasswordField } = VM.require( "buildhub.near/widget/components.password-field" ); +const { Checkbox } = VM.require("buildhub.near/widget/components.checkbox"); const Heading = styled.h2` color: white; @@ -17,6 +18,7 @@ const Heading = styled.h2` const [value, setValue] = useState(""); const [password, setPassword] = useState(""); +const [checked, setChecked] = useState(false); return (
@@ -85,6 +87,11 @@ return ( onChange={(e) => setPassword(e.target.value)} placeholder={"Password"} /> + setChecked(!checked)} + label="Checkbox" + />
From 47d12e613c4d8d7f8c8344d910b9fddbb4f05471 Mon Sep 17 00:00:00 2001 From: Zeeshan Ahmad Date: Thu, 4 Jan 2024 00:54:38 +0500 Subject: [PATCH 06/34] Add Textbox --- apps/builddao/widget/components/library.jsx | 2 + apps/builddao/widget/components/text-box.jsx | 43 ++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 apps/builddao/widget/components/text-box.jsx diff --git a/apps/builddao/widget/components/library.jsx b/apps/builddao/widget/components/library.jsx index 84ced475..2eba8db8 100644 --- a/apps/builddao/widget/components/library.jsx +++ b/apps/builddao/widget/components/library.jsx @@ -11,6 +11,7 @@ const { PasswordField } = VM.require( "buildhub.near/widget/components.password-field" ); const { Checkbox } = VM.require("buildhub.near/widget/components.checkbox"); +const { TextBox } = VM.require("buildhub.near/widget/components.text-box"); const Heading = styled.h2` color: white; @@ -92,6 +93,7 @@ return ( onChange={() => setChecked(!checked)} label="Checkbox" /> + diff --git a/apps/builddao/widget/components/text-box.jsx b/apps/builddao/widget/components/text-box.jsx new file mode 100644 index 00000000..b9df3117 --- /dev/null +++ b/apps/builddao/widget/components/text-box.jsx @@ -0,0 +1,43 @@ +const Label = styled.label` + color: var(--White-100, #fff); + + /* Body/16px */ + font-size: 16px; + font-style: normal; + font-weight: 400; + line-height: 170%; /* 27.2px */ +`; + +const TextArea = styled.textarea` + display: flex; + min-height: 100px; + padding: 16px 12px; + align-items: flex-start; + gap: 10px; + align-self: stretch; + + border-radius: 8px; + border: 1px solid var(--Stroke-color, rgba(255, 255, 255, 0.2)); + background: var(--Bg-1, #0b0c14); + + color: var(--White-50, #fff); + + /* Body/16px */ + font-size: 16px; + font-style: normal; + font-weight: 400; + line-height: 170%; /* 27.2px */ +`; + +function TextBox({ label, value, onChange, placeholder, maxWidth }) { + return ( +
+ +