Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
252e4be
wip on html button spec
softmarshmallow Jan 1, 2022
c857759
wip - add core.Button to web.Button connector
softmarshmallow Jan 1, 2022
9dfba10
add text data deligation
softmarshmallow Jan 3, 2022
b7babc7
add --as-input flag declaration
softmarshmallow Mar 18, 2022
5a7173b
add minimal html input text declaration
softmarshmallow Mar 18, 2022
909e996
add minimal html input handling prompt by flags
softmarshmallow Mar 18, 2022
ad9d7ee
MAJOR IMPACT - add single child scrollview as a wraping widtet, regis…
softmarshmallow Mar 18, 2022
05151ee
fix border side css builder
softmarshmallow Mar 18, 2022
6669607
input text support with simple inner text styles (no layouting yet)
softmarshmallow Mar 18, 2022
b705f1a
add general lyout styles mapper (no assignment yet)
softmarshmallow Mar 18, 2022
9207fab
add text field full styling support - inherits from container
softmarshmallow Mar 18, 2022
618b1c0
override input's width when it needs to be specified (when abs pos)
softmarshmallow Mar 18, 2022
3914f15
add flags interpreter safety - on error caused by user's fault
softmarshmallow Mar 18, 2022
b645fb3
Merge pull request #127 from gridaco/support-text-field
softmarshmallow Mar 18, 2022
f943553
don't explicitly specify text transform if set to 'none'
softmarshmallow Mar 18, 2022
1e7978e
Merge branch 'staging' of https://github.com/gridaco/designto-code in…
softmarshmallow Mar 18, 2022
569d00e
add --as-button flag declaration
softmarshmallow Mar 18, 2022
2feab0f
add button flag parsing
softmarshmallow Mar 19, 2022
79c6f95
add button flag parsing
softmarshmallow Mar 19, 2022
c79466a
add pseudo styling support for web widgets - supported by vanilla bui…
softmarshmallow Mar 19, 2022
7d809a5
add pseudo styling support for styled components
softmarshmallow Mar 19, 2022
f156022
sanitize
softmarshmallow Mar 19, 2022
852d65a
add button composer
softmarshmallow Mar 20, 2022
8170a40
mimic changes on css building
softmarshmallow Mar 20, 2022
da55d39
add button build support for web platforms
softmarshmallow Mar 20, 2022
9190ffa
Merge pull request #108 from gridaco/support-button
softmarshmallow Mar 20, 2022
bcf2007
registered --as-slider flag signature
softmarshmallow Mar 20, 2022
ae612da
bump reflect core with Slider declaration
softmarshmallow Mar 20, 2022
a8cd822
add slider support with flags (input/range progress color not support…
softmarshmallow Mar 21, 2022
92b24f1
Merge pull request #130 from gridaco/support-slider
softmarshmallow Mar 21, 2022
532c7fc
add slider support with flags (input/range progress color not support…
softmarshmallow Mar 22, 2022
0a3c5e9
Merge branch 'staging' of https://github.com/gridaco/designto-code in…
softmarshmallow Mar 22, 2022
ab8d90b
add simple obscure text casting with text value - if only contains '●…
softmarshmallow Mar 24, 2022
46958d1
fix input fill color matching
softmarshmallow Mar 24, 2022
de32f50
add autofocus flag signature
softmarshmallow Mar 24, 2022
6b1b906
no throw on unknown flag
softmarshmallow Mar 24, 2022
f9524bd
fix text field flag handling - null error
softmarshmallow Mar 24, 2022
b8f7c38
fix slider thumb color handling
softmarshmallow Mar 24, 2022
96acdcb
fix reflect core
softmarshmallow Mar 24, 2022
980cf9f
fix devtime router query warning issue
softmarshmallow Mar 24, 2022
7ac0e19
switch container for merging widgets to WrappingContainer
softmarshmallow Mar 24, 2022
ff917b9
disable button detection
softmarshmallow Mar 26, 2022
739184e
support simple css named colors
softmarshmallow Mar 26, 2022
8870e86
disable width override for button
softmarshmallow Mar 26, 2022
efde73b
clean flutter widget builder
softmarshmallow Mar 26, 2022
89a61d7
add TODO: on vectorizer
softmarshmallow Mar 26, 2022
72d09f6
add title meta to editor pages with design name
softmarshmallow Mar 27, 2022
29ac016
support proper layout grow as expanded - flex: n for every elements
softmarshmallow Mar 27, 2022
3a63ab5
add fixed size support in autolayout along with `flex-shrink: 0`
softmarshmallow Mar 27, 2022
f550331
flex styling cleanups
softmarshmallow Mar 27, 2022
3e2a185
update style mapper class signature
softmarshmallow Mar 28, 2022
b4a9447
add css style optimizer comparing logics
softmarshmallow Mar 28, 2022
673e923
clean imports
softmarshmallow Mar 28, 2022
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 editor/components/app-runner/vanilla-app-runner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export function VanillaRunner({
if (ref.current && enableInspector) {
ref.current.onload = () => {
const matches = ref.current.contentDocument.querySelectorAll(
"div, span, button, img, image, svg"
"div, span, img, image, svg" // button, input - disabled due to interaction testing (for users)
);
matches.forEach((el) => {
const tint = "rgba(20, 0, 255, 0.2)";
Expand Down
22 changes: 22 additions & 0 deletions editor/components/editor/editor-browser-meta-head/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React from "react";
import Head from "next/head";
import { useEditorState } from "core/states";

export function EditorBrowserMetaHead({
children,
}: {
children: React.ReactChild;
}) {
const [state] = useEditorState();

return (
<>
<Head>
<title>
{state?.design?.name ? `Grida | ${state?.design?.name}` : "Loading.."}
</title>
</Head>
{children}
</>
);
}
1 change: 1 addition & 0 deletions editor/components/editor/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from "./editor-appbar";
export * from "./editor-browser-meta-head";
export * from "./editor-layer-hierarchy";
export * from "./editor-sidebar";
20 changes: 16 additions & 4 deletions editor/core/reducers/editor-reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,14 @@ export function editorReducer(state: EditorState, action: Action): EditorState {
console.info("cleard console by editorReducer#select-node");

// update router
router.query.node = node ?? state.selectedPage;
router.push(router);
router.push(
{
pathname: router.pathname,
query: { ...router.query, node: node ?? state.selectedPage },
},
undefined,
{}
);

return produce(state, (draft) => {
const _canvas_state_store = new CanvasStateStore(
Expand All @@ -42,8 +48,14 @@ export function editorReducer(state: EditorState, action: Action): EditorState {
console.info("cleard console by editorReducer#select-page");

// update router
router.query.node = page;
router.push(router);
router.push(
{
pathname: router.pathname,
query: { ...router.query, node: page },
},
undefined,
{}
);

return produce(state, (draft) => {
const _canvas_state_store = new CanvasStateStore(filekey, page);
Expand Down
5 changes: 5 additions & 0 deletions editor/core/states/editor-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ export interface EditorSnapshot {
}

export interface FigmaReflectRepository {
/**
* name of the file
*/
name: string;

/**
* fileid; filekey
*/
Expand Down
6 changes: 5 additions & 1 deletion editor/pages/files/[key]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { useDesignFile } from "hooks";

import { warmup } from "scaffolds/editor";
import { FileResponse } from "@design-sdk/figma-remote-types";
import { EditorBrowserMetaHead } from "components/editor";

export default function FileEntryEditor() {
const router = useRouter();
Expand Down Expand Up @@ -64,6 +65,7 @@ export default function FileEntryEditor() {
selectedPage: warmup.selectedPage(prevstate, pages, nodeid && [nodeid]),
selectedLayersOnPreview: [],
design: {
name: file.name,
input: null,
components: components,
// styles: null,
Expand Down Expand Up @@ -131,7 +133,9 @@ export default function FileEntryEditor() {
<SigninToContinueBannerPrmoptProvider>
<StateProvider state={safe_value} dispatch={handleDispatch}>
<EditorDefaultProviders>
<Editor loading={loading} />
<EditorBrowserMetaHead>
<Editor loading={loading} />
</EditorBrowserMetaHead>
</EditorDefaultProviders>
</StateProvider>
</SigninToContinueBannerPrmoptProvider>
Expand Down
4 changes: 4 additions & 0 deletions editor/pages/files/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { useEffect, useState } from "react";
import Head from "next/head";
import { DefaultEditorWorkspaceLayout } from "layouts/default-editor-workspace-layout";
import {
Cards,
Expand All @@ -19,6 +20,9 @@ export default function FilesPage() {

return (
<>
<Head>
<title>Grida | files</title>
</Head>
<DefaultEditorWorkspaceLayout
backgroundColor={colors.color_editor_bg_on_dark}
leftbar={<HomeSidebar />}
Expand Down
13 changes: 11 additions & 2 deletions editor/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
import React from "react";
import Head from "next/head";

import { HomeInput } from "scaffolds/home-input";
import { HomeDashboard } from "scaffolds/home-dashboard";
import React from "react";
import { useAuthState } from "hooks/use-auth-state";

export default function Home() {
const authstate = useAuthState();

// region - dev injected
return <HomeDashboard />;
return (
<>
<Head>
<title>Grida | Home</title>
</Head>
<HomeDashboard />
</>
);
// endregion

switch (authstate) {
Expand Down
22 changes: 1 addition & 21 deletions editor/scaffolds/editor/warmup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@ import {
import { createInitialWorkspaceState } from "core/states";
import { workspaceReducer } from "core/reducers";
import { PendingState } from "core/utility-types";
import { DesignInput } from "@designto/config/input";
import { TargetNodeConfig } from "query/target-node";
import { WorkspaceAction } from "core/actions";
import { FileResponse } from "@design-sdk/figma-remote-types";
import { convert } from "@design-sdk/figma-node-conversion";
import { mapper } from "@design-sdk/figma-remote";
import { find, visit } from "tree-visit";
import { visit } from "tree-visit";

const pending_workspace_state = createPendingWorkspaceState();
//
Expand Down Expand Up @@ -98,24 +96,6 @@ export function componentsFrom(
.reduce(tomap, {});
}

export function initializeDesign(design: TargetNodeConfig): EditorSnapshot {
return {
selectedNodes: [design.node],
selectedLayersOnPreview: [],
selectedPage: null,
design: {
pages: [],
components: null,
// styles: null,
key: design.file,
input: DesignInput.fromApiResponse({
...design,
entry: design.reflect,
}),
},
};
}

export function safestate(initialState) {
return initialState.type === "success"
? initialState.value
Expand Down
2 changes: 1 addition & 1 deletion externals/design-sdk
2 changes: 1 addition & 1 deletion externals/reflect-core
4 changes: 4 additions & 0 deletions packages/builder-css-styles/border/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ export function border(border: Border): CSSProperties {
}

export function borderSide(borderSide: BorderSide): CSSProperty.Border {
if (borderSide.style === "none") {
return "none";
}

return `${borderSide.style ?? "solid"} ${px(borderSide.width)} ${color(
borderSide.color
)}`;
Expand Down
32 changes: 30 additions & 2 deletions packages/builder-css-styles/color/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ export function color(input: CssColorInputLike | Color): string {
} else if (input instanceof CssNamedColor) {
return input.name;
} else if (typeof input == "object") {
// with alpha
if ("r" in input && "a" in input) {
// with alpha (if alpha is 1, use rgb format instead)
if ("r" in input && "a" in input && input.a !== 1) {
const a = safe_alpha_fallback(validAlphaValue(input.a));
const rgba = input as ICssRGBA;
const _r = validColorValue(rgba.r) ?? 0;
Expand All @@ -31,6 +31,11 @@ export function color(input: CssColorInputLike | Color): string {
// no alpha
else if ("r" in input && "a"! in input) {
const rgb = input as RGB;
const named = namedcolor(rgb);
if (named) {
return named;
}

return `rgb(${validColorValue(rgb.r) ?? 0}, ${
validColorValue(rgb.g) ?? 0
}, ${validColorValue(rgb.b) ?? 0})`;
Expand All @@ -42,6 +47,29 @@ export function color(input: CssColorInputLike | Color): string {
}
}

/**
* rgb value of white, black as named colors
* @param rgb
*/
const namedcolor = (rgb: RGB) => {
// black
if (rgb.r === 0 && rgb.g === 0 && rgb.b === 0) {
return "black";
}
// white
if (rgb.r === 1 && rgb.g === 1 && rgb.b === 1) {
return "white";
}
// blue
if (rgb.r === 0 && rgb.g === 0 && rgb.b === 1) {
return "blue";
}
// red
if (rgb.r === 1 && rgb.g === 0 && rgb.b === 0) {
return "red";
}
};

const validColorValue = (f: number) => {
if (f === undefined) {
return;
Expand Down
1 change: 1 addition & 0 deletions packages/builder-css-styles/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export * from "./font-weight";
export * from "./font-family";
export * from "./text-decoration";
export * from "./text-shadow";
export * from "./text-transform";
export * from "./gradient";
export * from "./padding";
export * from "./margin";
Expand Down
21 changes: 13 additions & 8 deletions packages/builder-css-styles/padding/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,13 @@ import { px } from "../dimensions";

type PaddingValue = number | "auto";

export function padding(p: EdgeInsets): CSSProperties {
switch (edgeInsetsShorthandMode(p)) {
export function padding(
p: EdgeInsets,
options?: {
explicit?: boolean;
}
): CSSProperties {
switch (edgeInsetsShorthandMode(p, options)) {
case EdgeInsetsShorthandMode.empty: {
return {};
}
Expand All @@ -31,10 +36,10 @@ export function padding(p: EdgeInsets): CSSProperties {
case EdgeInsetsShorthandMode.trbl:
default: {
return {
"padding-bottom": _makeifRequired(p?.bottom),
"padding-top": _makeifRequired(p?.top),
"padding-left": _makeifRequired(p?.left),
"padding-right": _makeifRequired(p?.right),
"padding-bottom": _makeifRequired(p?.bottom, options?.explicit),
"padding-top": _makeifRequired(p?.top, options?.explicit),
"padding-left": _makeifRequired(p?.left, options?.explicit),
"padding-right": _makeifRequired(p?.right, options?.explicit),
};
}
}
Expand All @@ -55,8 +60,8 @@ function _pv(pv: PaddingValue) {
return px(pv);
}

function _makeifRequired(val: number): string | undefined {
if (val && val > 0) {
function _makeifRequired(val: number, explicit?: boolean): string | undefined {
if (explicit || (val && val > 0)) {
return px(val);
}
}
2 changes: 1 addition & 1 deletion packages/builder-css-styles/text-shadow/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { color } from "../color";
import { px } from "../dimensions";

export function textShadow(ts: TextShadowManifest[]): string {
if (ts.length === 0) {
if (!ts || ts.length === 0) {
return;
}

Expand Down
20 changes: 20 additions & 0 deletions packages/builder-css-styles/text-transform/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { TextTransform } from "@reflect-ui/core";

export function textTransform(tt: TextTransform) {
switch (tt) {
case TextTransform.capitalize:
return "capitalize";
case TextTransform.lowercase:
return "lowercase";
case TextTransform.uppercase:
return "uppercase";
case TextTransform.fullwidth:
return "full-width";
case TextTransform.fullsizekana:
return "full-size-kana";
case TextTransform.none:
default:
// for none, we don't explicitly set it - to make it shorter.
return;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,16 @@ export function flexsizing({
case MainAxisSize.max: {
return {
"align-self": "stretch",
width: width && length(width),
height: height && length(height),
};
}
case MainAxisSize.min: {
switch (direction) {
case Axis.horizontal:
case Axis.vertical:
return {
flex: "none",
flex: flex > 0 ? flex : "none", // 1+
width: width && length(width),
height: height && length(height),
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
} from "@web-builder/react-core";
import {
buildJsx,
getWidgetStylesConfigMap,
StylesConfigMapBuilder,
JSXWithoutStyleElementConfig,
JSXWithStyleElementConfig,
WidgetStyleConfigMap,
Expand Down Expand Up @@ -48,7 +48,8 @@ export class ReactNativeInlineStyleBuilder {
private readonly widgetName: string;
readonly config: reactnative_config.ReactNativeInlineStyleConfig;
private readonly namer: ScopedVariableNamer;
private readonly stylesConfigWidgetMap: WidgetStyleConfigMap;
private readonly stylesMapper: StylesConfigMapBuilder;
// private readonly stylesConfigWidgetMap: WidgetStyleConfigMap;

constructor({
entry,
Expand All @@ -64,7 +65,8 @@ export class ReactNativeInlineStyleBuilder {
entry.key.id,
ReservedKeywordPlatformPresets.react
);
this.stylesConfigWidgetMap = getWidgetStylesConfigMap(entry, {

this.stylesMapper = new StylesConfigMapBuilder(entry, {
namer: this.namer,
rename_tag: false,
});
Expand All @@ -73,7 +75,7 @@ export class ReactNativeInlineStyleBuilder {
private stylesConfig(
id: string
): JSXWithStyleElementConfig | JSXWithoutStyleElementConfig {
return this.stylesConfigWidgetMap.get(id);
return this.stylesMapper.map.get(id);
}

private jsxBuilder(widget: JsxWidget) {
Expand Down
Loading