-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from Quest-Protocol/feat/frontend
front end and app
- Loading branch information
Showing
18 changed files
with
2,461 additions
and
242 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,76 @@ | ||
return <Widget src="/*__@appAccount__*//widget/pages.Dashboard"></Widget>; | ||
const { page, ...passProps } = props; | ||
|
||
const { AppLayout } = VM.require( | ||
"/*__@appAccount__*//widget/components.Layout" | ||
); | ||
|
||
if (!AppLayout) { | ||
return <p>Loading modules...</p>; | ||
} | ||
|
||
// CSS styles to be used across the app. | ||
// Define fonts here, as well as any other global styles. | ||
const Theme = styled.div` | ||
a { | ||
color: inherit; | ||
} | ||
width: 100%; | ||
height: 100vh; | ||
`; | ||
|
||
if (!page) { | ||
// If no page is specified, we default to the feed page TEMP | ||
page = "dashboard"; | ||
} | ||
|
||
// This is our navigation, rendering the page based on the page parameter | ||
function Page() { | ||
const routes = page.split("."); | ||
switch (routes[0]) { | ||
case "dashboard": { | ||
return ( | ||
<Widget | ||
src="/*__@appAccount__*//widget/pages.Dashboard" | ||
props={passProps} | ||
/> | ||
); | ||
} | ||
case "discover": { | ||
return ( | ||
<Widget | ||
src="/*__@appAccount__*//widget/pages.Discover" | ||
props={passProps} | ||
/> | ||
); | ||
} | ||
case "create": { | ||
return ( | ||
<Widget | ||
src="/*__@appAccount__*//widget/pages.Create" | ||
props={passProps} | ||
/> | ||
); | ||
} | ||
case "quest": { | ||
return ( | ||
<Widget | ||
src="/*__@appAccount__*//widget/pages.Quest" | ||
props={passProps} | ||
/> | ||
); | ||
} | ||
default: { | ||
// TODO: 404 page | ||
return <p>404</p>; | ||
} | ||
} | ||
} | ||
|
||
return ( | ||
<Theme> | ||
<AppLayout page={page}> | ||
<Page /> | ||
</AppLayout> | ||
</Theme> | ||
); |
46 changes: 46 additions & 0 deletions
46
questverse-widgets/apps/QuestVerse/widget/components/Header.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
const Toolbar = styled.div` | ||
margin-left: 20px; | ||
@media only screen and (max-width: 1061px) { | ||
margin: 10px 0 0 0; | ||
} | ||
`; | ||
|
||
const registryContract = "registry.i-am-human.near"; | ||
const issuer = "fractal.i-am-human.near"; | ||
|
||
// SBT verification | ||
let isVerified = false; | ||
const userSBTs = Near.view("registry.i-am-human.near", "sbt_tokens_by_owner", { | ||
account: context.accountId, | ||
}); | ||
|
||
for (let i = 0; i < userSBTs.length; i++) { | ||
if ("fractal.i-am-human.near" == userSBTs[i][0]) { | ||
isVerified = true; | ||
} | ||
} | ||
|
||
return ( | ||
<div className="d-flex p-3 px-4 align-items-center rounded justify-content-between bg-black"> | ||
<h3 className="mt-2" style={{ fontFamily: "Courier", color: "white" }}> | ||
<Link to="//*__@appAccount__*//widget/app"> | ||
<b>QuestVerse</b> | ||
</Link> | ||
</h3> | ||
<Toolbar> | ||
{!isVerified ? ( | ||
<Widget | ||
src="hack.near/widget/n.style" | ||
props={{ | ||
Link: { | ||
text: "Get Verified", | ||
href: "https://i-am-human.app/", | ||
}, | ||
}} | ||
/> | ||
) : ( | ||
<Widget src="hack.near/widget/start" /> | ||
)} | ||
</Toolbar> | ||
</div> | ||
); |
60 changes: 60 additions & 0 deletions
60
questverse-widgets/apps/QuestVerse/widget/components/Layout.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
const Container = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
width: 100%; | ||
height: auto; | ||
min-height: 100vh; | ||
background: #f4f4f4; | ||
margin-top: calc(-1 * var(--body-top-padding)); | ||
`; | ||
|
||
const ContentContainer = styled.div` | ||
flex: 1; | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
width: 100%; | ||
`; | ||
|
||
const Header = styled.div` | ||
background: black; | ||
`; | ||
|
||
const registryContract = "registry.i-am-human.near"; | ||
const issuer = "fractal.i-am-human.near"; | ||
|
||
// SBT verification | ||
let isVerified = false; | ||
const userSBTs = Near.view("registry.i-am-human.near", "sbt_tokens_by_owner", { | ||
account: props.accountId ?? context.accountId, | ||
}); | ||
|
||
for (let i = 0; i < userSBTs.length; i++) { | ||
if ("fractal.i-am-human.near" == userSBTs[i][0]) { | ||
isVerified = true; | ||
} | ||
} | ||
|
||
const AppHeader = ({ page }) => ( | ||
<Widget src="/*__@appAccount__*//widget/components.Header" props={{ page }} /> | ||
); | ||
|
||
const Footer = ({ page }) => { | ||
return <></>; | ||
}; | ||
|
||
function AppLayout({ page, children }) { | ||
return ( | ||
<> | ||
<Container> | ||
<AppHeader page={page} /> | ||
<ContentContainer>{children}</ContentContainer> | ||
<Footer page={page} /> | ||
</Container> | ||
</> | ||
); | ||
} | ||
|
||
return { AppLayout }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
questverse-widgets/apps/QuestVerse/widget/components/quest/create/footer.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
const nextChildren = props.isLast ? ( | ||
<> | ||
Create Quest <i className="bi bi-check2" /> | ||
</> | ||
) : ( | ||
<> | ||
Next step <i className="bi bi-chevron-right" /> | ||
</> | ||
); | ||
const hasPrevious = props.hasPrevious; | ||
const onReset = props.onReset ?? (() => {}); | ||
const onNext = props.onNext ?? (() => {}); | ||
const onPrevious = props.onPrevious ?? (() => {}); | ||
|
||
return ( | ||
<div className="d-flex align-items-center gap-2 mt-5"> | ||
<Widget | ||
src="nearui.near/widget/Input.Button" | ||
props={{ | ||
children: "Reset steps", | ||
variant: "danger outline", | ||
size: "lg", | ||
className: "me-auto", | ||
onClick: onReset, | ||
}} | ||
/> | ||
<Widget | ||
src="nearui.near/widget/Input.Button" | ||
props={{ | ||
children: ( | ||
<> | ||
<i className="bi bi-chevron-left" /> Previous step | ||
</> | ||
), | ||
variant: "info outline", | ||
size: "lg", | ||
onClick: onPrevious, | ||
className: hasPrevious ? undefined : "d-none", | ||
}} | ||
/> | ||
<Widget | ||
src="nearui.near/widget/Input.Button" | ||
props={{ | ||
children: nextChildren, | ||
variant: "info", | ||
size: "lg", | ||
onClick: onNext, | ||
buttonProps: { | ||
type: "submit", | ||
}, | ||
}} | ||
/> | ||
</div> | ||
); |
Oops, something went wrong.