diff --git a/instances/treasury-devdao.near/widget/app.jsx b/instances/treasury-devdao.near/widget/app.jsx index a9233012..edcfc545 100644 --- a/instances/treasury-devdao.near/widget/app.jsx +++ b/instances/treasury-devdao.near/widget/app.jsx @@ -11,6 +11,7 @@ const { AppLayout } = VM.require( ) || { AppLayout: () => <> }; const instance = "${REPL_INSTANCE}"; +const treasuryDaoID = "${REPL_TREASURY}"; const { Theme } = VM.require(`${instance}/widget/config.css`) || { Theme: () => <>, @@ -84,7 +85,7 @@ function Page() { return ( - + diff --git a/instances/treasury-devdao.near/widget/components/Approvers.jsx b/instances/treasury-devdao.near/widget/components/Approvers.jsx index 3103e968..aa2b9605 100644 --- a/instances/treasury-devdao.near/widget/components/Approvers.jsx +++ b/instances/treasury-devdao.near/widget/components/Approvers.jsx @@ -20,15 +20,7 @@ const Container = styled.div` .grey-circle { width: 40px; height: 40px; - background-color: #e2e6ec; - } - - .reject { - color: #d20000; - } - - .approve { - color: #089968; + background-color: var(--grey-04); } `; @@ -139,11 +131,12 @@ return (
{voted ? ( {votesStatus}{" "} @@ -159,6 +152,7 @@ return (
), children: ApproversComponent, + instance: props.instance, }} /> ) : ( diff --git a/instances/treasury-devdao.near/widget/components/DropDownWithSearchAndManualRequest.jsx b/instances/treasury-devdao.near/widget/components/DropDownWithSearchAndManualRequest.jsx index a7f02094..03bc2f2a 100644 --- a/instances/treasury-devdao.near/widget/components/DropDownWithSearchAndManualRequest.jsx +++ b/instances/treasury-devdao.near/widget/components/DropDownWithSearchAndManualRequest.jsx @@ -95,7 +95,7 @@ const Container = styled.div` } .selected { - background-color: var(--grey-05); + background-color: var(--grey-04); } .cursor-pointer { diff --git a/instances/treasury-devdao.near/widget/components/HistoryStatus.jsx b/instances/treasury-devdao.near/widget/components/HistoryStatus.jsx index 7eee07ff..20b20bed 100644 --- a/instances/treasury-devdao.near/widget/components/HistoryStatus.jsx +++ b/instances/treasury-devdao.near/widget/components/HistoryStatus.jsx @@ -3,23 +3,23 @@ const isPaymentsPage = props.isPaymentsPage; const Container = styled.div` text-align: center; .reject { - background-color: rgba(0, 0, 0, 0.08); - color: #1b1b18; + background-color: var(--grey-04); + color: var(--text-color); } .approve { background-color: rgba(0, 202, 134, 0.16); - color: #089968; + color: var(--other-green); } .expire { background-color: rgba(255, 122, 0, 0.16); - color: #de6a00; + color: var(--other-warning); } .failed { background-color: rgba(239, 56, 38, 0.1); - color: #ef3826; + color: var(--other-red); } `; diff --git a/instances/treasury-devdao.near/widget/components/OverlayTrigger.jsx b/instances/treasury-devdao.near/widget/components/OverlayTrigger.jsx index 50b07b1c..6bc5c128 100644 --- a/instances/treasury-devdao.near/widget/components/OverlayTrigger.jsx +++ b/instances/treasury-devdao.near/widget/components/OverlayTrigger.jsx @@ -1,4 +1,12 @@ -const config = Near.view("${REPL_TREASURY}", "get_config"); +const { instance } = props; + +if (!instance) { + return <>; +} + +const { treasuryDaoID } = VM.require(`${instance}/widget/config.data`); + +const config = Near.view(treasuryDaoID, "get_config"); const metadata = JSON.parse(atob(config.metadata ?? "")); const isDarkTheme = metadata.theme === "dark"; @@ -23,14 +31,13 @@ State.init({ show: false, }); -const overlayClassName = - props.overlayClassName ?? "border m-3 p-3 rounded-4 shadow"; +const overlayClassName = props.overlayClassName ?? "m-3 p-2 rounded-3 shadow"; const overlayStyle = props.overlayStyle ?? { maxWidth: "24em", zIndex: 1070, backgroundColor: isDarkTheme ? "#222222" : "#f4f4f4", color: isDarkTheme ? "#CACACA" : "#1B1B18", - borderColor: isDarkTheme ? "#3B3B3B" : "rgba(226, 230, 236, 1)", + border: "1px solid " + (isDarkTheme ? "#3B3B3B" : "rgba(226, 230, 236, 1)"), }; const overlay = ( diff --git a/instances/treasury-devdao.near/widget/components/ProposalStatus.jsx b/instances/treasury-devdao.near/widget/components/ProposalStatus.jsx index ad30d162..89254654 100644 --- a/instances/treasury-devdao.near/widget/components/ProposalStatus.jsx +++ b/instances/treasury-devdao.near/widget/components/ProposalStatus.jsx @@ -2,12 +2,12 @@ const status = props.status; const Container = styled.div` .reject { background-color: rgba(220, 102, 102, 0.16); - color: #d20000; + color: var(--other-red); } .approve { background-color: rgba(0, 202, 134, 0.16); - color: #089968; + color: var(--other-green); } `; diff --git a/instances/treasury-devdao.near/widget/components/ReceiverAccount.jsx b/instances/treasury-devdao.near/widget/components/ReceiverAccount.jsx index 22ca2714..14e41517 100644 --- a/instances/treasury-devdao.near/widget/components/ReceiverAccount.jsx +++ b/instances/treasury-devdao.near/widget/components/ReceiverAccount.jsx @@ -91,6 +91,7 @@ return ( props={{ popup: verificationStatus && , children: ReceiverAccountComponent, + instance: props.instance, }} /> ) : ( diff --git a/instances/treasury-devdao.near/widget/components/TokensDropdown.jsx b/instances/treasury-devdao.near/widget/components/TokensDropdown.jsx index 973d1e7d..c6a8af51 100644 --- a/instances/treasury-devdao.near/widget/components/TokensDropdown.jsx +++ b/instances/treasury-devdao.near/widget/components/TokensDropdown.jsx @@ -160,7 +160,7 @@ const Container = styled.div` } .selected { - background-color: var(--grey-05); + background-color: var(--grey-04); } .cursor-pointer { diff --git a/instances/treasury-devdao.near/widget/components/ValidatorsDropDownWithSearch.jsx b/instances/treasury-devdao.near/widget/components/ValidatorsDropDownWithSearch.jsx index 457d3780..7b4dbd45 100644 --- a/instances/treasury-devdao.near/widget/components/ValidatorsDropDownWithSearch.jsx +++ b/instances/treasury-devdao.near/widget/components/ValidatorsDropDownWithSearch.jsx @@ -71,7 +71,7 @@ const Container = styled.div` } .selected { - background-color: var(--grey-05); + background-color: var(--grey-04); } .cursor-pointer { diff --git a/instances/treasury-devdao.near/widget/components/Votes.jsx b/instances/treasury-devdao.near/widget/components/Votes.jsx index 5fdb3836..e8068da2 100644 --- a/instances/treasury-devdao.near/widget/components/Votes.jsx +++ b/instances/treasury-devdao.near/widget/components/Votes.jsx @@ -8,9 +8,9 @@ const getPercentage = (value) => const Container = styled.div` .bar { - background-color: #e2e6ec; + background-color: var(--grey-04); width: 100px; - height: 20px; + height: 10px; overflow: hidden; } .flex-item { diff --git a/instances/treasury-devdao.near/widget/components/templates/AppLayout.jsx b/instances/treasury-devdao.near/widget/components/templates/AppLayout.jsx index c616abd1..bcb664b2 100644 --- a/instances/treasury-devdao.near/widget/components/templates/AppLayout.jsx +++ b/instances/treasury-devdao.near/widget/components/templates/AppLayout.jsx @@ -1,17 +1,25 @@ -const data = fetch(`https://httpbin.org/headers`); -const gatewayURL = data?.body?.headers?.Origin ?? ""; +const AppHeader = ({ page, instance }) => ( + +); -const config = Near.view("${REPL_TREASURY}", "get_config"); -const metadata = JSON.parse(atob(config.metadata ?? "")); +function AppLayout({ page, instance, children, treasuryDaoID }) { + const config = Near.view(treasuryDaoID, "get_config"); + const metadata = JSON.parse(atob(config.metadata ?? "")); -const isDarkTheme = true; -// false; + const data = fetch(`https://httpbin.org/headers`); + const gatewayURL = data?.body?.headers?.Origin ?? ""; + const isDarkTheme = metadata.theme === "dark"; -const getColors = (isDarkTheme) => ` + const getColors = (isDarkTheme) => ` --bg-header-color: ${isDarkTheme ? "#222222" : "#2C3E50"}; - --bg-page-color: ${isDarkTheme ? "#222222" : "#f4f4f4"}; + --bg-page-color: ${isDarkTheme ? "#222222" : "#FFFFFF"}; --bg-system-color: ${isDarkTheme ? "#131313" : "#f4f4f4"}; - --bg-card-color: ${isDarkTheme ? "#222222" : "#FFFFFF"}; --text-color: ${isDarkTheme ? "#CACACA" : "#1B1B18"}; --text-secondary-color: ${isDarkTheme ? "#878787" : "#999999"}; --text-alt-color: ${isDarkTheme ? "#FFFFFF" : "#FFFFFF"}; @@ -30,336 +38,322 @@ const getColors = (isDarkTheme) => ` --other-red:#D95C4A; // bootstrap theme color - --bs-body-bg: var(--bg-card-color); + --bs-body-bg: var(--bg-page-color); --bs-border-color: var(--border-color); + --bs-dropdown-link-hover-color: var(--grey-04); `; -const ParentContainer = styled.div` - ${({ isDarkTheme }) => getColors(isDarkTheme)} - width: 100%; - background: var(--bg-page-color) !important; - ${({ gatewayURL }) => - gatewayURL.includes("near.org") - ? ` + const ParentContainer = styled.div` + ${() => getColors(isDarkTheme)} + width: 100%; + background: var(--bg-system-color) !important; + ${() => + gatewayURL.includes("near.org") + ? ` /* Styles specific to near.org */ position: static; ` - : ` + : ` /* Styles specific to other URLs */ position: fixed; inset: 73px 0px 0px; overflow-y: scroll; `} -`; + `; + + const Theme = styled.div` + padding-top: calc(-1 * var(--body-top-padding)); + + // remove up/down arrow in input of type = number + /* For Chrome, Safari, and Edge */ + input[type="number"]::-webkit-outer-spin-button, + input[type="number"]::-webkit-inner-spin-button { + -webkit-appearance: none; + margin: 0; + } + + /* For Firefox */ + input[type="number"] { + -moz-appearance: textfield; + } -const Theme = styled.div` - padding-top: calc(-1 * var(--body-top-padding)); - - // remove up/down arrow in input of type = number - /* For Chrome, Safari, and Edge */ - input[type="number"]::-webkit-outer-spin-button, - input[type="number"]::-webkit-inner-spin-button { - -webkit-appearance: none; - margin: 0; - } - - /* For Firefox */ - input[type="number"] { - -moz-appearance: textfield; - } - - .card { - border-color: var(--border-color) !important; - border-width: 1px !important; - border-radius: 14px; - background-color: var(--bg-card-color) !important; - } - - .dropdown-menu { - background-color: var(--bg-card-color) !important; - color: var(--text-color) !important; - } - - .dropdown-item.active, - .dropdown-item:active { - background-color: var(--bg-card-color) !important; - color: inherit !important; - } - - .offcanvas { - background-color: var(--bg-card-color) !important; - color: var(--text-color) !important; - } - - color: var(--text-color); - - a { - text-decoration: none; - color: var(--link-inactive-color) !important; - &.active { - color: var(--link-active-color) !important; - font-weight: 700 !important; - } - - &:hover { + .card { + border-color: var(--border-color) !important; + border-width: 1px !important; + border-radius: 14px; + background-color: var(--bg-page-color) !important; + } + + .dropdown-menu { + background-color: var(--bg-page-color) !important; + color: var(--text-color) !important; + } + + .dropdown-item.active, + .dropdown-item:active { + background-color: var(--grey-04) !important; + color: inherit !important; + } + + .offcanvas { + background-color: var(--bg-page-color) !important; + color: var(--text-color) !important; + } + + color: var(--text-color); + + a { text-decoration: none; - color: var(--link-active-color) !important; - font-weight: 700 !important; + color: var(--link-inactive-color) !important; + &.active { + color: var(--link-active-color) !important; + font-weight: 700 !important; + } + + &:hover { + text-decoration: none; + color: var(--link-active-color) !important; + font-weight: 700 !important; + } } - } - button.primary { - background: var(--theme-color) !important; - color: var(--text-alt-color) !important; - border: none !important; - padding-block: 0.7rem !important; - i { + button.primary { + background: var(--theme-color) !important; color: var(--text-alt-color) !important; + border: none !important; + padding-block: 0.7rem !important; + i { + color: var(--text-alt-color) !important; + } } - } - .primary-button { - background: var(--theme-color) !important; - color: var(--text-alt-color) !important; - border: none !important; - i { + .primary-button { + background: var(--theme-color) !important; color: var(--text-alt-color) !important; + border: none !important; + i { + color: var(--text-alt-color) !important; + } } - } - - .text-lg { - font-size: 15px; - } - - .fw-semi-bold { - font-weight: 500; - } - - .text-secondary { - color: var(--text-secondary-color) !important; - } - - .max-w-100 { - max-width: 100%; - } - - .custom-truncate { - display: -webkit-box; - -webkit-line-clamp: 3; - -webkit-box-orient: vertical; - overflow: hidden; - text-overflow: ellipsis; - line-height: 1.5; - max-height: 4.5em; - text-align: left; - } - - .display-none { - display: none; - } - - .text-right { - text-align: end; - } - - .text-left { - text-align: left; - } - .text-underline { - text-decoration: underline !important; - } - - .bg-highlight { - background-color: rgb(185, 185, 185, 0.2); - } - - .cursor-pointer { - cursor: pointer; - } - - .theme-btn { - background: var(--theme-color) !important; - color: white !important; - border: none; - } - - .theme-btn.btn:hover { - color: white !important; - } - - .toast-container { - right: 10px !important; - bottom: 10px !important; - } - .toast { - border-radius: 10px; - overflow: hidden; - color: var(--text-color) !important; - background: var(--bg-card-color) !important; - border-color: var(--border-color) !important; - a { - color: inherit !important; - &:active { + .text-lg { + font-size: 15px; + } + + .fw-semi-bold { + font-weight: 500; + } + + .text-secondary { + color: var(--text-secondary-color) !important; + } + + .max-w-100 { + max-width: 100%; + } + + .custom-truncate { + display: -webkit-box; + -webkit-line-clamp: 3; + -webkit-box-orient: vertical; + overflow: hidden; + text-overflow: ellipsis; + line-height: 1.5; + max-height: 4.5em; + text-align: left; + } + + .display-none { + display: none; + } + + .text-right { + text-align: end; + } + + .text-left { + text-align: left; + } + .text-underline { + text-decoration: underline !important; + } + + .bg-highlight { + background-color: rgb(185, 185, 185, 0.2); + } + + .cursor-pointer { + cursor: pointer; + } + + .theme-btn { + background: var(--theme-color) !important; + color: white !important; + border: none; + } + + .theme-btn.btn:hover { + color: white !important; + } + + .toast-container { + right: 10px !important; + bottom: 10px !important; + } + .toast { + border-radius: 10px; + overflow: hidden; + color: var(--text-color) !important; + background: var(--bg-page-color) !important; + border-color: var(--border-color) !important; + + a { color: inherit !important; + &:active { + color: inherit !important; + } + &:hover { + color: inherit !important; + } } + } + + .toast-header { + background-color: var(--bg-system-color) !important; + color: var(--text-secondary-color) !important; + } + + .text-md { + font-size: 15px; + } + + .primary-text-color { + color: var(--theme-color); + a { + color: var(--theme-color) !important; + } + + i { + color: var(--theme-color) !important; + } + } + + .btn-outline.btn:hover { + color: inherit !important; + } + + .btn-outline-plain { + padding-block: 8px !important; + padding-inline: 10px !important; + border-radius: 0.375rem !important; + border: 1.5px solid var(--border-color) !important; + background-color: var(--bg-page-color) !important; + color: var(--text-color) !important; + &:hover { - color: inherit !important; + background-color: white; + color: black; } } - } - .toast-header { - background-color: var(--bg-system-color) !important; - color: var(--text-secondary-color) !important; - } + h6, + .h6, + h5, + .h5, + h4, + .h4, + h3, + .h3, + h2, + .h2, + h1, + .h1 { + color: var(--text-color) !important; + } - .text-md { - font-size: 15px; - } + .table { + border-color: var(--border-color) !important; + color: var(--text-color) !important; + } - .primary-text-color { - color: var(--theme-color); - a { - color: var(--theme-color) !important; - } - - i { - color: var(--theme-color) !important; - } - } - - .btn-outline.btn:hover { - color: inherit !important; - } - - .btn-outline-plain { - padding-block: 8px !important; - padding-inline: 10px !important; - border-radius: 0.375rem !important; - border: 1.5px solid var(--border-color) !important; - background-color: var(--bg-card-color) !important; - color: var(--text-color) !important; - - &:hover { - background-color: white; - color: black; - } - } - - h6, - .h6, - h5, - .h5, - h4, - .h4, - h3, - .h3, - h2, - .h2, - h1, - .h1 { - color: var(--text-color) !important; - } - - .table { - border-color: var(--border-color) !important; - color: var(--text-color) !important; - } - - .bg-white { - background-color: var(--bg-page-color) !important; - color: var(--text-color) !important; - } - - .bg-dropdown { - background-color: var(--bg-card-color) !important; - color: var(--text-color) !important; - } - - .bg-custom-overlay { - background-color: var(--bg-page-color) !important; - color: var(--text-color) !important; - } - - .fill-accent { - fill: var(--theme-color); - } - - .use-max-bg { - color: #007aff; - cursor: pointer; - } - - .bg-validator-info { - background: rgba(0, 16, 61, 0.06); - color: #1b1b18; - padding-inline: 0.8rem; - padding-block: 0.5rem; - font-weight: 500; - font-size: 13px; - } - - .bg-validator-warning { - background: rgba(255, 158, 0, 0.1); - color: var(--other-warning); - padding-inline: 0.8rem; - padding-block: 0.5rem; - font-weight: 500; - font-size: 13px; - } - - .bg-withdraw-warning { - background: rgba(255, 158, 0, 0.1); - color: var(--other-warning); - padding-inline: 0.8rem; - padding-block: 0.5rem; - font-weight: 500; - font-size: 13px; - } - - .text-sm { - font-size: 13px; - } - - .text-secondary a { - color: inherit !important; - } - - .text-delete { - color: var(--other-red) !important; - - i { - color: var(--other-red) !important; + .bg-white { + background-color: var(--bg-page-color) !important; + color: var(--text-color) !important; } - } - .btn-outline.btn:hover { - color: inherit !important; - } + .bg-dropdown { + background-color: var(--bg-page-color) !important; + color: var(--text-color) !important; + } - .border-right { - border-right: 1px solid var(--border-color); - } -`; + .bg-custom-overlay { + background-color: var(--bg-page-color) !important; + color: var(--text-color) !important; + } -const AppHeader = ({ page, instance }) => ( - -); + .fill-accent { + fill: var(--theme-color); + } + + .use-max-bg { + color: #007aff; + cursor: pointer; + } + + .bg-validator-info { + background: rgba(0, 16, 61, 0.06); + color: #1b1b18; + padding-inline: 0.8rem; + padding-block: 0.5rem; + font-weight: 500; + font-size: 13px; + } + + .bg-validator-warning { + background: rgba(255, 158, 0, 0.1); + color: var(--other-warning); + padding-inline: 0.8rem; + padding-block: 0.5rem; + font-weight: 500; + font-size: 13px; + } + + .bg-withdraw-warning { + background: rgba(255, 158, 0, 0.1); + color: var(--other-warning); + padding-inline: 0.8rem; + padding-block: 0.5rem; + font-weight: 500; + font-size: 13px; + } + + .text-sm { + font-size: 13px; + } + + .text-secondary a { + color: inherit !important; + } + + .text-delete { + color: var(--other-red) !important; + + i { + color: var(--other-red) !important; + } + } + + .btn-outline.btn:hover { + color: inherit !important; + } + + .border-right { + border-right: 1px solid var(--border-color); + } + `; -function AppLayout({ page, instance, children }) { return ( - +
{children}
diff --git a/instances/treasury-devdao.near/widget/lib/skeleton.jsx b/instances/treasury-devdao.near/widget/lib/skeleton.jsx index c7407f97..4c37b049 100644 --- a/instances/treasury-devdao.near/widget/lib/skeleton.jsx +++ b/instances/treasury-devdao.near/widget/lib/skeleton.jsx @@ -1,5 +1,5 @@ const Skeleton = styled.div` - background: #efefef; + background: var(--grey-04); animation: pulse 1.5s ease-in-out infinite; @keyframes pulse { diff --git a/instances/treasury-devdao.near/widget/pages/dashboard/Chart.jsx b/instances/treasury-devdao.near/widget/pages/dashboard/Chart.jsx index 70a61e1c..28505fec 100644 --- a/instances/treasury-devdao.near/widget/pages/dashboard/Chart.jsx +++ b/instances/treasury-devdao.near/widget/pages/dashboard/Chart.jsx @@ -1,4 +1,10 @@ -const { nearPrice, ftTokens, accountId, title } = props; +const { nearPrice, ftTokens, accountId, title, instance } = props; + +if (!instance) { + return <>; +} + +const { treasuryDaoID } = VM.require(`${instance}/widget/config.data`); const { Skeleton } = VM.require( "${REPL_BASE_DEPLOYMENT_ACCOUNT}/widget/lib.skeleton" @@ -43,8 +49,13 @@ function formatCurrency(amount) { .replace(/\B(?=(\d{3})+(?!\d))/g, ","); } +const config = Near.view(treasuryDaoID, "get_config"); +const metadata = JSON.parse(atob(config.metadata ?? "")); + +const isDarkTheme = metadata.theme === "dark"; + const code = ` - + @@ -53,24 +64,30 @@ const code = ` - - - - `; -const daoPolicy = Near.view(treasuryDaoID, "get_policy"); -const config = Near.view(treasuryDaoID, "get_config"); -const metadata = JSON.parse(atob(config.metadata ?? "")); - function toBase64(json) { return Buffer.from(JSON.stringify(json)).toString("base64"); } @@ -247,7 +248,7 @@ function onSubmitClick() { ...metadata, primaryColor: color, flagLogo: image, - theme: selectedTheme, + theme: selectedTheme.value, }), }, }, @@ -262,7 +263,9 @@ function onSubmitClick() { function setDefault() { setImage(metadata?.flagLogo ?? defaultImage); setColor(metadata?.primaryColor ?? defaultColor); - setSelectedTheme(metadata?.theme ?? ThemeOptions[0]); + setSelectedTheme( + ThemeOptions.find((i) => i.value === metadata?.theme) ?? ThemeOptions[0] + ); } useEffect(() => { @@ -273,7 +276,7 @@ useEffect(() => { return ( -
+
{!metadata ? (
) : ( -
-