Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SDK - Update UX of Record Tab #918

Merged
merged 2 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion website/src/main.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ function Main() {
/>
</Sider>
<Layout>
<Content style={{ padding: "50px 50px" }}>
<Content style={{ padding: "50px 50px", margin: "0 auto", minWidth: "850px" }}>
<Outlet />
</Content>
<Footer style={{ textAlign: "center", display:"flex", flexDirection: "column" }}>
Expand Down
14 changes: 14 additions & 0 deletions website/src/pages/Homepage.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@
font-size: 14px;
}

.buttonRow {
display: flex;
flex-direction: column;
align-items: center;
gap: 20px;
}


.button {
background-color: #12e172;
padding: 16px 32px 16px 32px;
Expand Down Expand Up @@ -93,6 +101,12 @@ a:nth-child(3) {
font-size: 18px;
}

.buttonRow {
display: flex;
flex-direction: row;
gap: 20px;
}

.actionRow {
display: flex;
flex-direction: row;
Expand Down
16 changes: 14 additions & 2 deletions website/src/pages/Homepage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,28 @@ const Homepage = () => {
The tooling for building zero-knowledge applications at your
fingertips
</p>{" "}
<div className="buttonRow">
<Link
target="_blank"
rel="noopener noreferrer"
to="/account"
>
<button className="button">
{" "}
Try now <span className="arrow">&rarr;</span>{" "}
</button>
</Link>{" "}
<Link
target="_blank"
rel="noopener noreferrer"
to="https://developer.aleo.org/sdk/"
>
<button className="button">
{" "}
View Docs <span className="arrow">&rarr;</span>{" "}
See Docs <span className="arrow">&rarr;</span>{" "}
</button>
</Link>{" "}
</div>
<ul className="actionRow">
<Link to="/account" className="actionItem">
{" "}
Expand Down Expand Up @@ -58,7 +70,7 @@ const Homepage = () => {
to="https://docs.leo-lang.org/sdk/create-leo-app/tutorial/"
>
<button className="button">
Try it now <span className="arrow">&rarr;</span>
Try now <span className="arrow">&rarr;</span>
</button>
</Link>{" "}
<div className="footer">
Expand Down
3 changes: 3 additions & 0 deletions website/src/tabs/record/DecryptRecord.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.container {
max-width: 750px;
}
172 changes: 104 additions & 68 deletions website/src/tabs/record/DecryptRecord.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { useState } from "react";
import { Button, Card, Col, Divider, Form, Input, Row, Skeleton } from "antd";
import { CopyButton } from "../../components/CopyButton";
import { useAleoWASM } from "../../aleo-wasm-hook";
import "./DecryptRecord.css";

export const DecryptRecord = () => {
const [ciphertext, setCiphertext] = useState(null);
Expand Down Expand Up @@ -81,81 +82,116 @@ export const DecryptRecord = () => {
ciphertext !== null ? ciphertext.toString() : "";

return (
<Card
title="Decrypt Record"
style={{ width: "100%" }}
extra={
<Button
type="primary"

size="middle"
onClick={populateForm}
>
Demo
</Button>
}
>
<Form {...layout}>
<Form.Item label="Record (Ciphertext)" colon={false}>
<Input
name="recordCiphertext"
size="large"
placeholder="Record (Ciphertext)"
allowClear
onChange={onCiphertextChange}
value={recordCipherTextString()}
/>
</Form.Item>
<Form.Item label="View Key" colon={false}>
<Input
name="viewKey"
size="large"
placeholder="View Key"
allowClear
onChange={onViewKeyChange}
value={viewKeyString()}
/>
</Form.Item>
</Form>
{ciphertext || viewKey ? (
<Row justify="center">
<Col>
<div className="container">
<h1>Records</h1>
<h2>Overview</h2>
<ul>
<li>
{" "}
Records are created by Aleo programs and can be used as
inputs for functions within the same program. Once a
record is used, it’s consumed and can’t be reused.
</li>
<li>
Functions that consume records generate new records as
output.
</li>
<li>
Records are <strong>private</strong> by default, tied to
a single Aleo program and a user's private key.
</li>
<li>
The <strong> View Key </strong> is derived from the
private key and allows users to decrypt their encrypted
data and prove ownership of that data.
</li>
</ul>

<br />
<p>
Try the demo below! Enter a record and
decrypt it using your View Key to experience how the process
works. You can also click the "Show Demo" button on the
right to generate an example.
</p>

<br />

<Card
title="Decrypt Record"
style={{ width: "100%" }}
extra={
<>
<Button

type="primary"
size="middle"
onClick={clearForm}
onClick={populateForm}
>
Clear
Show Demo
</Button>
</Col>
</Row>
) : null}
{
</>
}
>
<Form {...layout}>
<Divider />
<Form.Item label="Record (Plaintext)" colon={false}>
{plaintext ? (
<Row align="middle">
<Col span={23}>
<Input.TextArea
size="large"
rows={10}
placeholder="Record (Plaintext)"
value={recordPlaintext()}
disabled
/>
</Col>
<Col span={1} align="middle">
<CopyButton data={recordPlaintext()} />
</Col>
</Row>
) : (
<Skeleton active />
)}
<Form.Item label="Record (Ciphertext)" colon={false}>
<Input
name="recordCiphertext"
size="large"
placeholder="Record (Ciphertext)"
allowClear
onChange={onCiphertextChange}
value={recordCipherTextString()}
/>
</Form.Item>
<Form.Item label="View Key" colon={false}>
<Input
name="viewKey"
size="large"
placeholder="View Key"
allowClear
onChange={onViewKeyChange}
value={viewKeyString()}
/>
</Form.Item>
</Form>
}
</Card>
{ciphertext || viewKey ? (
<Row justify="center">
<Col>
<Button size="middle" onClick={clearForm}>
Clear
</Button>
</Col>
</Row>
) : null}
{
<Form {...layout}>
<Divider />
<Form.Item label="Record (Plaintext)" colon={false}>
{plaintext ? (
<Row align="middle">
<Col span={23}>
<Input.TextArea
size="large"
rows={10}
placeholder="Record (Plaintext)"
value={recordPlaintext()}
disabled
/>
</Col>
<Col span={1} align="middle">
<CopyButton
data={recordPlaintext()}
/>
</Col>
</Row>
) : (
<Skeleton active />
)}
</Form.Item>
</Form>
}
</Card>
</div>
);
} else {
return (
Expand Down
Loading