Skip to content

Commit d62a6eb

Browse files
Merge pull request #146 from gridaco/staging
Staging
2 parents 085d9e4 + 38895f2 commit d62a6eb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+916
-17776
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ yarn figma
5050
yarn sketch
5151

5252
# [OPTIONAL 3 & Contributors only] run plugin ui in webdev mode
53-
yarn webdev
53+
yarn web
54+
# visit http://localhost:3000/init-webdev to work on browser
5455
```
5556

5657
_soon as the subpackages are released as stable, we will remove git submodule dependency for ease of use. until then, this will be the primary repository and all the edits and PRs will be caused by this project._ - [Learn more here](https://github.com/bridgedxyz/.github/blob/main/contributing/working-with-submodules.md)

app/lib/auth/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ export async function isAuthenticated() {
5252
return (await AuthStorage.get())?.length > 1; // using 1 (same as != undefined.)
5353
}
5454

55+
export async function getAccessToken(): Promise<string> {
56+
return await AuthStorage.get();
57+
}
58+
5559
export async function checkAuthSession(session: string): Promise<boolean> {
5660
// TODO:
5761
const res = await __auth_proxy.checkProxyAuthResult(
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import React from "react";
2+
3+
export function CheckIcon() {
4+
return (
5+
<svg
6+
width="20"
7+
height="20"
8+
viewBox="0 0 20 20"
9+
xmlns="http://www.w3.org/2000/svg"
10+
>
11+
<path d="M10 0C4.48 0 0 4.48 0 10C0 15.52 4.48 20 10 20C15.52 20 20 15.52 20 10C20 4.48 15.52 0 10 0ZM7.29 14.29L3.7 10.7C3.31 10.31 3.31 9.68 3.7 9.29C4.09 8.9 4.72 8.9 5.11 9.29L8 12.17L14.88 5.29C15.27 4.9 15.9 4.9 16.29 5.29C16.68 5.68 16.68 6.31 16.29 6.7L8.7 14.29C8.32 14.68 7.68 14.68 7.29 14.29Z" />
12+
</svg>
13+
);
14+
}

app/lib/components/animation/animated-check-icon.tsx

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React from "react";
22
import styled from "@emotion/styled";
33

44
import { motion } from "framer-motion";
5+
import { CheckIcon } from "../Icon/check-icon";
56

67
const variants = {
78
"make-active": {
@@ -14,20 +15,16 @@ const variants = {
1415

1516
export function AnimatedCheckIcon() {
1617
return (
17-
<CheckIcon
18+
<StyledCheckIcon
1819
style={{
1920
marginRight: "9px",
2021
}}
2122
variants={variants}
2223
initial={{ fill: "#C1C1C1" }}
23-
width="20"
24-
height="20"
25-
viewBox="0 0 20 20"
26-
xmlns="http://www.w3.org/2000/svg"
2724
>
28-
<path d="M10 0C4.48 0 0 4.48 0 10C0 15.52 4.48 20 10 20C15.52 20 20 15.52 20 10C20 4.48 15.52 0 10 0ZM7.29 14.29L3.7 10.7C3.31 10.31 3.31 9.68 3.7 9.29C4.09 8.9 4.72 8.9 5.11 9.29L8 12.17L14.88 5.29C15.27 4.9 15.9 4.9 16.29 5.29C16.68 5.68 16.68 6.31 16.29 6.7L8.7 14.29C8.32 14.68 7.68 14.68 7.29 14.29Z" />
29-
</CheckIcon>
25+
<CheckIcon />
26+
</StyledCheckIcon>
3027
);
3128
}
3229

33-
const CheckIcon = styled(motion.svg)``;
30+
const StyledCheckIcon = styled(motion.div)``;

app/lib/components/animation/progress-bar.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@ import styled from "@emotion/styled";
33

44
import { AnimatePresence, motion } from "framer-motion";
55

6-
export function ProgressBar() {
6+
interface IProgressBar {
7+
contorl?: () => void;
8+
}
9+
10+
export function ProgressBar(props: IProgressBar) {
711
return (
812
<Background>
913
<AnimatePresence>
@@ -15,6 +19,7 @@ export function ProgressBar() {
1519
duration: 10,
1620
delay: 2,
1721
}}
22+
onAnimationComplete={props.contorl}
1823
/>
1924
</AnimatePresence>
2025
</Background>
@@ -24,9 +29,9 @@ export function ProgressBar() {
2429
const Background = styled.div`
2530
background: #f5f5f5;
2631
27-
// for reset body padding
28-
margin-left: -8px;
29-
margin-right: -8px;
32+
// for reset body and parent padding
33+
margin-left: -20px;
34+
margin-right: -20px;
3035
`;
3136

3237
const Bar = styled(motion.div)`

app/lib/components/icons-loader.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ function filterIcons(
223223
return [k, item];
224224
})
225225
.filter((k) => k !== undefined);
226-
console.log("default icons", defaultIcons.length);
226+
console.log("default icons loaded", defaultIcons.length);
227227
return defaultIcons;
228228
}
229229

@@ -278,7 +278,6 @@ function IconItem(props: { name: string; config: IconConfig }) {
278278

279279
const onClick = () => {
280280
_onUserLoadIconToCanvas();
281-
console.log("icon", name, "clicked");
282281
loadData().then((d) => {
283282
parent.postMessage(
284283
{

app/lib/components/upload-steps.tsx

Lines changed: 19 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { ProgressBar } from "./animation/progress-bar";
66
import { AnimatedCheckIcon } from "./animation/animated-check-icon";
77
import { motion } from "framer-motion";
88
import { Preview } from ".";
9+
import { CheckIcon } from "./Icon/check-icon";
910

1011
const step = [
1112
"converting design to universal format",
@@ -16,17 +17,6 @@ const step = [
1617
"running tests",
1718
];
1819

19-
const loadingVariants = {
20-
"make-active": {
21-
// display: "none",
22-
// opacity: 1,
23-
// transitionEnd: {
24-
// display: "none",
25-
// },
26-
transition: { duration: 1 },
27-
},
28-
};
29-
3020
const fieldVariants = {
3121
"make-active": {
3222
transition: { staggerChildren: 0.8, delayChildren: 1 },
@@ -40,38 +30,26 @@ const itemVariants = {
4030
},
4131
};
4232

43-
const finishVariants = {
44-
"make-active": {
45-
display: "none",
46-
transition: { display: "block" },
47-
},
48-
};
49-
5033
export function UploadSteps() {
5134
const [isLoading, setIsLoading] = useState(true);
5235

53-
useEffect(() => {
54-
console.log(isLoading);
55-
}, [isLoading]);
36+
function animateHandle() {
37+
setIsLoading(!isLoading);
38+
}
39+
5640
return (
5741
<>
5842
<Preview auto />
43+
{isLoading && <ProgressBar contorl={animateHandle} />}
5944
<InnerWrapper variants={fieldVariants} animate="make-active">
6045
{isLoading ? (
61-
<Loading variants={loadingVariants} animate="make-active">
62-
<ProgressBar />
46+
<Loading>
6347
<Title>
6448
Uploading your design
6549
<br />
6650
“button”
6751
</Title>
68-
<StepsWrapper
69-
variants={fieldVariants}
70-
animate="make-active"
71-
onTransitionEnd={() => {
72-
setIsLoading(!isLoading);
73-
}}
74-
>
52+
<StepsWrapper variants={fieldVariants} animate="make-active">
7553
{step.map((item, i) => (
7654
<Field key={`Upload-Step-${item}-${i}`} variants={itemVariants}>
7755
<Icon />
@@ -84,9 +62,12 @@ export function UploadSteps() {
8462
</Loading>
8563
) : (
8664
<>
87-
<Finish variants={finishVariants} initial={{ display: "none" }}>
65+
<Finish>
8866
<Field>
89-
<Icon></Icon>
67+
<IconBox>
68+
<CheckIcon />
69+
</IconBox>
70+
9071
<Title>Your design is ready</Title>
9172
</Field>
9273
<Item>
@@ -113,11 +94,11 @@ const InnerWrapper = styled(motion.div)`
11394
/* display: none; */
11495
`;
11596

116-
const Loading = styled(motion.div)`
97+
const Loading = styled.div`
11798
/* display: none; */
11899
`;
119100

120-
const Finish = styled(motion.div)`
101+
const Finish = styled.div`
121102
/* display: none; */
122103
`;
123104

@@ -143,9 +124,6 @@ const Field = styled(motion.div)`
143124
}
144125
`;
145126
const Icon = styled(AnimatedCheckIcon)`
146-
/* width: 16px;
147-
height: 16px;
148-
line-height: 19px; */
149127
margin-right: 9px;
150128
`;
151129

@@ -164,6 +142,10 @@ const FooterButtonWrapper = styled.div`
164142
bottom: 8px;
165143
width: calc(100% - 40px);
166144
`;
145+
const IconBox = styled.div`
146+
fill: #6cd470;
147+
margin-right: 9px;
148+
`;
167149

168150
const CheckButton = styled(Button)`
169151
${BlackButton};

app/lib/main/index.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -307,9 +307,6 @@ function _update_focused_screen_ev(screen: WorkScreen) {
307307
},
308308
"*"
309309
);
310-
console.log(
311-
`sending back thread about changed screen (user interest) data - "${screen}"`
312-
);
313310
}
314311

315312
const Wrapper = styled.div`

app/lib/pages/code/code-screen.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,14 @@ import { make_empty_selection_state_text_content } from "./constants";
1616
import { format } from "./formatter";
1717
import copy from "copy-to-clipboard";
1818
import { PluginSdk } from "@plugin-sdk/app";
19-
import { CodeScreenFooter } from "./code-screen-footer";
19+
import { CodeScreenFooter } from "./footer-action/code-screen-footer";
2020
import { CodeOptionsControl } from "./code-options-control";
2121
import { fromApp, CodeGenRequest } from "./__plugin/events";
2222
import { useSingleSelection } from "../../utils/plugin-hooks";
2323

2424
type DesigntoCodeUserOptions = FrameworkOption;
25-
interface ICodeScreen {}
2625

27-
export function CodeScreen(props: ICodeScreen) {
26+
export function CodeScreen() {
2827
const [app, setApp] = useState<string>();
2928
const [useroption, setUseroption] = React.useState<DesigntoCodeUserOptions>(
3029
all_preset_options_map__prod.flutter_default
@@ -167,7 +166,11 @@ export function CodeScreen(props: ICodeScreen) {
167166
/>
168167
</CodeWrapper>
169168

170-
<CodeScreenFooter app={app} />
169+
<CodeScreenFooter
170+
framework={useroption.framework}
171+
app={app}
172+
scene={selection?.node as any}
173+
/>
171174
</div>
172175
);
173176
}

app/lib/pages/code/code-screen-footer.tsx renamed to app/lib/pages/code/footer-action/code-screen-footer.tsx

Lines changed: 26 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
import React, { useState } from "react";
22
import styled from "@emotion/styled";
3-
import { BlackButton, WhtieButton } from "../../components/style/global-style";
3+
import { WhtieButton } from "../../../components/style/global-style";
44
import { assistant as analytics } from "@analytics.bridged.xyz/internal";
55
import { PluginSdk } from "@plugin-sdk/app";
6-
import { quickLook } from "../../quicklook";
6+
import { preview } from "../../../scene-view";
7+
import { NextUploadButton } from "./next-upload-button";
8+
import type { ReflectSceneNode } from "@design-sdk/core/nodes";
9+
import { Framework } from "../framework-option";
710

811
interface ICodeScreenFooter {
12+
framework: Framework;
913
app?: any;
14+
scene?: ReflectSceneNode;
1015
}
1116

1217
export function CodeScreenFooter(props: ICodeScreenFooter) {
@@ -18,7 +23,7 @@ export function CodeScreenFooter(props: ICodeScreenFooter) {
1823
};
1924

2025
setLoadingState(true);
21-
quickLook("quicklook", props.app)
26+
preview("quicklook", props.app)
2227
.then((r) => {
2328
setLoadingState(false);
2429
PluginSdk.notify("quick look ready !");
@@ -32,24 +37,26 @@ export function CodeScreenFooter(props: ICodeScreenFooter) {
3237
// ANALYTICS
3338
analytics.event_click_quicklook();
3439
};
40+
41+
/** currently we only support uploading & preview for flutter */
42+
const _can_enable_next = props.framework == Framework.flutter && !!props.app;
43+
const _can_show_preview = props.framework == Framework.flutter && !!props.app;
44+
3545
return (
3646
<CodeFooterCtaWrapper>
37-
<NextStepButton
38-
disabled={!props.app}
39-
onClick={() => {
40-
// TODO: the button component should be passed from outer side.
41-
}}
42-
>
43-
Next
44-
</NextStepButton>
45-
{props.app && (
46-
<PreviewButton
47-
disabled={isLaunchingConsole}
48-
onClick={onQuickLookClicked}
49-
>
50-
{isLaunchingConsole ? "launching.." : "preview"}
51-
</PreviewButton>
52-
)}
47+
{
48+
<>
49+
<NextUploadButton disabled={!_can_enable_next} {...props} />
50+
{_can_show_preview && (
51+
<PreviewButton
52+
disabled={isLaunchingConsole}
53+
onClick={onQuickLookClicked}
54+
>
55+
{isLaunchingConsole ? "launching.." : "preview"}
56+
</PreviewButton>
57+
)}
58+
</>
59+
}
5360
</CodeFooterCtaWrapper>
5461
);
5562
}
@@ -70,22 +77,6 @@ const CodeFooterCtaWrapper = styled.footer`
7077
}
7178
}
7279
`;
73-
74-
const NextStepButton = styled.button`
75-
${BlackButton}
76-
/* 2/3 size. 12 is wrapper padding */
77-
width: calc(66.666% - 12px);
78-
79-
&:hover {
80-
color: #fff;
81-
background: #17181a;
82-
}
83-
&:disabled {
84-
color: #bbbbbb;
85-
background: #949494;
86-
}
87-
`;
88-
8980
const PreviewButton = styled.button`
9081
${WhtieButton}
9182
/* 1/3 size. 12 is wrapper padding */

0 commit comments

Comments
 (0)