GithubHelp home page GithubHelp logo

gridaco / code Goto Github PK

View Code? Open in Web Editor NEW
206.0 206.0 26.0 32.39 MB

Design to Code Engine

Home Page: https://grida.co/code

License: Apache License 2.0

TypeScript 96.02% JavaScript 2.42% Shell 0.01% CSS 0.87% HTML 0.34% Python 0.33%
code-generation design-to-code figma figma-html figma-react flutter works-with-flutter works-with-react works-with-svelte works-with-vue

code's People

Contributors

gwonheejun avatar junhoyeo avatar softmarshmallow avatar you-j avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

code's Issues

[Feature request] Long text as variable

example long text

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut finibus feugiat erat, vel molestie justo congue a. Vestibulum 
cursus, dui eu mattis ultricies, lacus diam pulvinar nunc, ac commodo leo enim tincidunt ligula. Cras id quam convallis, luctus 
purus sed, facilisis velit. Donec non dignissim tellus. Cras magna odio, ullamcorper sed hendrerit a, efficitur aliquam arcu. 
Fusce congue malesuada iaculis. Nullam in sem sem. Nunc sed tellus feugiat, scelerisque tellus et, ullamcorper sapien. Nunc 
fringilla luctus tristique. Sed viverra ornare dui, id vehicula leo feugiat scelerisque. Cras quis egestas leo, vitae luctus quam. 
Mauris vulputate vulputate justo, vel commodo eros vestibulum vel. Duis cursus, ante id malesuada placerat, lacus purus 
viverra libero, ut ornare ante dui ac purus. Cras congue leo quis felis bibendum, at finibus ex egestas. Donec consectetur 
libero ex, eu iaculis ex semper vitae.

rather than

<Text>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut finibus feugiat erat, vel molestie justo congue a. Vestibulum 
cursus, dui eu mattis ultricies, lacus diam pulvinar nunc, ac commodo leo enim tincidunt ligula. Cras id quam convallis, luctus 
purus sed, facilisis velit. Donec non dignissim tellus. Cras magna odio, ullamcorper sed hendrerit a, efficitur aliquam arcu. 
Fusce congue malesuada iaculis. Nullam in sem sem. Nunc sed tellus feugiat, scelerisque tellus et, ullamcorper sapien. Nunc 
fringilla luctus tristique. Sed viverra ornare dui, id vehicula leo feugiat scelerisque. Cras quis egestas leo, vitae luctus quam. 
Mauris vulputate vulputate justo, vel commodo eros vestibulum vel. Duis cursus, ante id malesuada placerat, lacus purus 
viverra libero, ut ornare ante dui ac purus. Cras congue leo quis felis bibendum, at finibus ex egestas. Donec consectetur 
libero ex, eu iaculis ex semper vitae.</Text>

would be better

const text = `Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut finibus feugiat erat, vel molestie justo congue a. 
Vestibulum cursus, dui eu mattis ultricies, lacus diam pulvinar nunc, ac commodo leo enim tincidunt ligula. Cras id quam 
convallis, luctus purus sed, facilisis velit. Donec non dignissim tellus. Cras magna odio, ullamcorper sed hendrerit a, efficitur 
aliquam arcu. Fusce congue malesuada iaculis. Nullam in sem sem. Nunc sed tellus feugiat, scelerisque tellus et, ullamcorper 
sapien. Nunc fringilla luctus tristique. Sed viverra ornare dui, id vehicula leo feugiat scelerisque. Cras quis egestas leo, vitae 
luctus quam. Mauris vulputate vulputate justo, vel commodo eros vestibulum vel. Duis cursus, ante id malesuada placerat, 
lacus purus viverra libero, ut ornare ante dui ac purus. Cras congue leo quis felis bibendum, at finibus ex egestas. Donec 
consectetur libero ex, eu iaculis ex semper vitae.`


<Text>{ text }</Text>

Html button autocomplete attribute on vuejs (vue-next)

Related - vuejs/core#4633

Html button

Attributes

name react vue svelte vanilla supported?
autofocus autoFocus autofocus autofocus
autocomplete autoComplete aria-autocomplete (?) autocomplete ❌ (dprecated)
disabled disabled disabled disabled
form (#1) form form form
formaction formAction formaction formaction
formenctype formEncType formenctype formenctype
formmethod formMethod formmethod formmethod
formnovalidate formNoValidate formnovalidate formnovalidate
name name name name
type type type type
value value value value

React

// from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/react/index.d.ts
interface ButtonHTMLAttributes<T> extends HTMLAttributes<T> {
  autoFocus?: boolean | undefined;
  disabled?: boolean | undefined;
  form?: string | undefined;
  formAction?: string | undefined;
  formEncType?: string | undefined;
  formMethod?: string | undefined;
  formNoValidate?: boolean | undefined;
  formTarget?: string | undefined;
  name?: string | undefined;
  type?: 'submit' | 'reset' | 'button' | undefined;
  value?: string | ReadonlyArray<string> | number | undefined;
}

Vue

<button
        autofocus
        aria-autocomplete=""
        disabled="false"
        form=""
        formaction=""
        formenctype=""
        formmethod=""
        formnovalidate
        name=""
        type=""
        value=""
        >
  Vue Button attributes demo
</button>

Tailwind css support

tailwindcss logo

Support - https://tailwindcss.com/ for web (css) platforms

Configurations by frameworks

  • CRA
  • NextJS

tailwind.config.js

https://tailwindcss.com/docs/configuration

Colors

tailwind css color references can be found here. (naming) https://tailwindcss.com/docs/customizing-colors
e.g. usage (background)

Layout

  • aspect-ratio
  • container
  • columns
  • break-after
  • break-before
  • break-inside
  • box-decoration-break
  • box-sizing
  • display
  • float
    • float-right
    • float-left
    • float-none
  • clear
    • clear-left
    • clear-right
    • clear-both
    • clear-none
  • isolation
  • object-fit
  • object-position
  • overflow
  • overscroll-behavior
  • position
  • top / right / bottom / left
  • visibility
  • z-index

Flexbox & Grid

Spacing

Sizing

Typography

Effects

Filters

Transitions & Animation

Transforms

Interactivity

SVG

Responsive

References

Font family, font name with space should be wrapped with `""`

Current output

const RootWrapperCheckingExistingComponents = styled.span`
	color: rgba(193, 193, 193, 1);
	text-overflow: ellipsis;
	font-size: 16px;
	font-family: Helvetica Neue;
	font-weight: 400;
	text-align: left;
	min-height: 19px;
	width: 265px;
`;

font-family: Helvetica Neue;

should be
font-family: "Helvetica Neue";

[new/auto-layout] Implement Responsive design with updated auto-layout capabilities

The new version of autolayout has been for a few weeks. learn more here

This enables us to make layout-perfect interpreting logic wihout infering from context, but as-is designed by designers.

We will now support plain html + css for starters, interpreting auto layout to flexbox properties.

We might also need global interpreter (reflect layouts) in which for converting layout configurations to flutter, web, and many other platforms in an intuitive way, through the unified logic gate.

[Cursor] Package Size Optimization

This is a thread for tracking package size & optimization strategy.
Current total packaging of @designto/code takes up 1.5mb (not accurate)

Our goal is to keep it under 1mb for in-browser & local use

[interpreter/text] text vertical align not working for flutter

flutter does not support built in textVerticalAlign support for widget "Text", but we can wrap with sizedbox and align. for to do this. we'll have to inspect parent of the text. But more importantly, the main problem is that we cannot know if text is vertically aligned and, + fitted to the box, if we can't know this, only option is to wrap all text -- which will get our generated code supre drity.

add custom formatter slot

Prettier for JS/TS, Dart format for dart, requires different modules, which can bring the default app size to increase. this formatter will be provided by remote api, but also can provide custom static formatter via local execution method.

[Web]Support text blur (layer-blur and background-blur)

Blur for text in figma is not working properly.

right: in figma, left: in chrome(web)

figma-blur-diff

The reason is that the method of applying blur to text is different from other methods.

In general, you need to do something other than css filter, backdrop-filter, or blur().

example

📌 [Roadmap] Frameworks support - Flutter / React / Vue / Svelte / Vanilla / Solid

Web

React

  • styled-components
  • styled-components (emotion)
  • styled-components (styled-components)
  • inline css
  • css in jsx
  • css module
  • class components
  • small components as const
  • export | export default
  • const | function for component
// const
const Container = () => { return <></>; }
// function
function Container () { return <></>; }

Preact

subset of react, with different imports handling
react vs preact - the differences

  • events don't bubble up through components
  • standard onInput should be used instead of React's onChange for form inputs (only if preact/compat is not used)
  • standard onDblClick should be used instead of React's onDoubleClick (only if preact/compat is not used)
  • onSearch should generally be used for , since the clear "x" button does not fire onInput in IE11

References

Vue

  • vue scoped style css
  • #138

Svelte

#163

Solid JS

#160

Vanilla

  • everything else
  • vanilla text escape - don't use jsx text escape

Flutter

Flutter support has different qualifications. Since it was supported before any others, we shall focus on supporting all previous highlight features.

  • Version up; synced token support - #38
  • Theme.of(context).textStyle.style support
  • Colors.name Named color support
  • FlatButton support
  • Remove redundant property specification. (don't specify default values)
  • Center support
  • LinearGradient support
  • Icons.icon_name support
  • StrutStyle.height support

improvement's needed

Thanks what i meant was to make a UI builder app that is simpler and inspired by WINDOWS.forms builder but for mobiles

Init Testing

  • visual testing
  • codegen output matching
  • snapshot taker
  • snapshot per screen sizes & compare
  • platforms support - flutter - flutter local build & visual comparison (also for android native & ios native - all other than native web platform)

Tools & Setup

to best match the "visual" factor of testing, we might need other option than jest

wip - searching for better solutions.

References

Add `object-position` support for web css images

It's rare to have a dedicated constraints on image, but for scenario like below, we need to specify the image's object-position so that targeted inner graphic content can be always visible.

support-image-object-position.mov

[Feature Request] Functional Token-indicating In-line documentation (a.k.a comments)

A Functional inline documentation.

There are two types of comment,

  1. General comment - for describing the behavior, explaining the code.
  2. Special comment - for indicating a block of token, that can be managed (synced bidirectionally) by design to code engine.

(suggestion) The syntax might look like,

import React from "react";

/**
 * ---------
 * https://code.grida.co/t/:p/:f/:id
 * [click to open design](https://code.grida.co/t/:p/:f/?redirect=design-origin)
 * [share this component](https://code.grida.co/t/:p/:f/?redirect=share-me)
 * (do not modify)
 * ---------
 */
function MyComponent(){
    return (
       <Wrapper>
           My component
       </Wrapper>
    );
}


/**
 * ---------
 * https://code.grida.co/t/:p/:f/:id
 * (do not modify)
 * ---------
 */
const Wrapper = styled.div`
    height: 100vh;
    width: 100vw;
`;

Challenges

  • Modification of code of managed token.
  • Modification (extending as new line) of token indicating comments.

What this can do

  • Bidirectional data sync
  • Previewing the design from vscode editor (withs url scheme)

Escaping text for vanilla html

image

Expected - the result on preview to have exact text "> Select Workspace" rather than jsx version of it - "{"> Select Workspace"}"

Text will special characters will be formatted via jsx text formatter, but since jsx text formatter is for react-only, for vue, html, and other native web-standard frameworks shall have a different text formatter.

e.g. vanilla-text-formatter or html-text-formatter

This shall be first implemented via CoLI

Test case - here

Add google fonts support

Add google fonts link import to web platforms, if available.

<!-- e.g. -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Source+Code+Pro:ital,wght@0,200;0,300;0,400;0,500;0,600;0,700;0,900;1,200;1,300;1,400;1,500;1,600;1,700;1,900&display=swap" rel="stylesheet">
  • search for google fonts repository if font family available
  • add only required font style

References

Towards Perfect Gradient support

Understanding Figma Gradient system - It's not like what you think!

Gradient in figma is bit different on render-styling (css) If you have LinearGradient - [(black 1) at 0%, (red 0) at 100%] Representation in css would be linear-gradient(90deg, rgba(0,0,0,1) 0%, rgba(255,0,0,0) 100%);, you might think. But this is incorrect.

To match a visually identical gradient, you need to have multiple gradient per colors. (Even if it is in a single fill item)

.single-fill-item {
  background: linear-gradient(90deg, black, transparent), linear-gradient(90deg, rgba(255, 0, 0, 1), transparent);
}

Note - Fallbacks on complex gradient

This is a technical issue, we will add support for complex gradient in the future.

Since perfectly providing a visually identical style code is redundant, we provide a fallback on complex gradient. (svg on web, png(optionally) on flutter)

Fallback cases

  • when gradient position does not starts from (or ends at) 0% or 100%
  • when gradient is not linear or radial.
  • when not one of the cases
    • n - s (0°) (supported)
    • s - n (180°) (supported)
    • e - w (270°) (supported)
    • w - e (90°) (supported)
    • nw - se (directional) (supported)
    • ne - sw (directional) (supported)
    • sw - ne (directional) (supported)
    • se - nw (directional) (supported)

📌 [Roadmap] Figma to Web - Missing features

Css properties to support

(update 21.10.06)

Global

    • opacity
    • visible
    • rotation ⚠

Fills

    • solid fill
    • image fill as background or background-image
    • width, height (only has group wrapper)
<GroupWrapper>
  // has size // has not size
  <Rectangle1 />
  <Rectangle2 />
</GroupWrapper>
    • linear gradient
    • solid color opacity
    • gradient opacity
    • fill (without stroke) opacity 100%
    • has multi color linear gradient
    • gradient degree
    • gradient stops
    • gradient alpha
    • radial gradient
    • gradient center
    • gradient radius
    • angular gradient
    • multiple fills
box-shadow: -7px -9px 3px rgba(98, 71, 20, 0.25), inset 9px 9px 12px rgba(40, 22, 4, 0.25);
    • border-radius (all)
    • border-radius (one)
    • opacity zero fill
    • layer (mix-blend-mode)
mix-blend-mode: color-dodge;

stroke

    • single solid border
    • stroke dash (in advanced stroke)
    • stroke dash cap (in advanced stroke)
    • stroke gap (in advanced stroke)
    • stroke end points cap (in advanced stroke)
    • stroke join (in advanced stroke)

boolean operation

    • responsive position (constraint)

masking

    • vector mask
    • rect mas
    • rrect mask
    • ⚠ ellipse mask
    • ⚠ image mask
    • ⚠ text mask
    • fallbacks

vector

    • Responsive position (constraint) (viewbox?)
    • ⚠ Vector on plugin version
    • ⚠ curvy lines

image fill

    • image fill (cover)
    • image opacity fill
    • image fit
    • image crop
    • image tile

ellipse

    • stroke

text

    • align-items
    • frame path
    • letter spacing
    • font family
    • font size
    • font-weight
    • precise font-weight - (e.g. currently ExtraBold gets converted to 700 instead on 800 & so on..)
    • position
    • h1-6 & p tag support
    • fill gradient - #84
    • mixed text style
    • text shadow
    • line-height undefined when auto (don't 100%)
    • automatize - width
    • line-height percentage calculation error
    • proper text formatting for raw html (vanilla) #72

Line ⚠

    • native line support - no fallback
    • rotation 0 / 180 / 360 line as divider
    • rotation n line as vector
<hr />

or

width: 837px;
height: 0px;

border: 1px solid #000000;

Autolayout Frame

    • fixed size

effects

    • background blur
    • layer blur
    • shadow + spread
    • shadow + offset
    • shadow + spread + offset
    • multi-shadow
    • shadow (flutter)
box-shadow: 0px 4px 24px rgba(255, 0, 0, 0.25), 0px 4px 4px rgba(255, 153, 0, 0.25);
    • inner-shadow (no text)
    • inner + outer-shadow (no text)
    • inner-shadow (text)
    • inner + outer-shadow (text)

Polygon

    • polygon

star

    • star

Support - Gradient value as variable

Gradient as variable with preview.

Gradients is often use as non variable, which is mostly used as highlight visual effects. - which also gets changed often to get the maximum blending visual. There are also cases gradient is almost constant, i.e. on a button, or when used as a branding identity.

Extracting non-registered gradient style as variable, making accessible to developers will have lot of benefits.

  1. using css variable
/* e.g. */
:root {
    --one-shot-linear-gradient-tangerine-to-yellow-45: linear-gradient(#e66465, #9198e5);
}
  1. using variable & injection
// 1. using ready to use css snippet
const __one_shot_linear_gradient_tangerine_to_yellow_45 = `linear-gradient(#e66465, #9198e5)`

const GradientBG = styled.div`
    background: ${__one_shot_linear_gradient_tangerine_to_yellow_45};
`


// 2. using custom injector
const __one_shot_linear_gradient_tangerine_to_yellow_45 = new LinearGradient("#e66465", "#9198e5");
const GradientBG = styled.div`
    background: ${css.lineargradient(__one_shot_linear_gradient_tangerine_to_yellow_45)};
`

This also applies to colors, long texts, spacing rules. While we are starting with gradient.

[Web/css] Overriding Useragent styles

Needs to be overridden .

  • h1 ~ margin-block property to 0px
  • on root, margin & padding to be 0px

Not all browsers have this same ua stylesheet, so we'll need some extra configuration of ua override / handling for web-css

[Feature Request] Readme generation (Semi Storybook support?)

Generation of documentation outside of the executable code (comment), A README.md or component.stories.mdx With preview included will help developers to manage their project structure & component hierarchy.

Challenges.

  • What happens when the component gets splitted? (What if source A and documentation A' does not match no longer?
  • What happens when user customize the documentation content?

References

Add cache support & publish as package

Converting original data to reflect format, detecting elements and converting it to code is a heavy work.
We need cache of each process and need to provide it as a option for user to enable use-cache option.

flutter `new Text` Assertion handling

image

It mostly prevented by explicit logic gate, but sometimes text with undefined text value happens.
and the flutter-builder prevents this, since flutter does not accepts empty text also.

This first happened while converting figma to flutter with this node

Frame with `border-radius` & clip content not clipping content on web (css)

Origin
image

The generated code
Screen Shot 2021-11-25 at 6 44 54 PM

Explicit overflow:hidden by user
Screen Shot 2021-11-25 at 6 45 08 PM

Although, we CAN'T always set overflow: hidden for clip content layout. this is because overflow property is also used for specifying scroll behavior on other logic gate (not sure with the execution order or importance between those two.)

The non-conflicting way is to use explicit clip-path just to specify the clipping behavior, eliminating possibility of logic conflict with scroll

[Discussion] Should we support BlendMode?

Should we support blend mode?

The options are..

  • yes - full support
  • no - ignore blendmode, but still export to code.
  • no - blend mode is only used on graphical elements, export it as graphics, always

example of unhandled blend mode.

Related

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.