Giter VIP home page Giter VIP logo

bricks's People

Contributors

dependabot[bot] avatar donfour avatar spikelu2016 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

Watchers

 avatar  avatar  avatar  avatar  avatar

bricks's Issues

Trying to import "./style.css" when React and CSS are selected in output settings

Describe the bug
Live preview crashes when React and CSS are selected in output settings. This is due the extra line import "./style.css" being generated when there's no CSS files being generated.

To Reproduce
Steps to reproduce the behavior:

  1. Select React and CSS in user settings
  2. Click generate code
  3. Live preview crashes because there's an import "./style.css" line, but we don't create any CSS files:

Screen Shot 2023-04-06 at 4 40 27 PM

Expected behavior
The import "./style.css" line should not exist when we don't generate any CSS files.

Log errors in Amplitude

Log errors in Amplitude so we can better track user issues:

// ui.tsx line 82
      socket.emit(
        "code-generation",
        { files: pluginMessage.files },
        withTimeout(
          (response) => {
            if (response.error) {
              console.error("There is an error from VS Code.");
              // TODO: log response.error to amplitude
              setCurrentPage(PAGES.ERROR);
            }
          },
// code.ts line 29
    } catch (e) {
      console.error(e); // TODO: log e.stack to amplitude
      figma.ui.postMessage({
        type: "generated-files",
        files: [],
        error: true,
      });

Set up CI/CD to run tests on push

Is your feature request related to a problem? Please describe.
Not good if people push code that breaks existing features.

Describe the solution you'd like
Set up Github Action to run all tests on every push.

Describe alternatives you've considered
n/a

Additional context
n/a

Add fonts rendering support in code generation using the new Bricks nodes

Is your feature request related to a problem? Please describe.
Currently, the Google Fonts Import URL in the CSS do not support multiple variants such as Regular, 500, italic. Right now the URL can only be like https://fonts.googleapis.com/css?family=Cantarell:italic|Droid+Serif:bold, we want to add support so it can also be like https://fonts.googleapis.com/css?family=Cantarell:italic,regular,500

Describe the solution you'd like
Integrate fonts with new Bricks node and add support for multi variants in the Google fonts URL.

Implement algorithm for grouping components

Describe the solution you'd like
Currently, Bricks computes positioning attributes through Figma's auto layout. Without auto layout, Bricks cannot generate code with accurate positioning. The solution is to segment the the design components and group them based on its locations within the parent component.

Screen Shot 2023-03-10 at 12 09 46 PM

When there's an error, Figma plugin will be stuck at loading screen.

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Let's say there's an error when generating code:
// figma/src/code.ts line 5
figma.ui.onmessage = async (msg) => {
  if (msg.type === "styled-bricks-nodes") {

    throw new Error("some random error"); // <- add to simulate error

    figma.ui.postMessage({
      type: "styled-bricks-nodes",
      files: await convertToCode(figma.currentPage.selection, {
        language: msg.options.language,
        cssFramework: msg.options.cssFramework,
        uiFramework: msg.options.uiFramework,
      }),
    });
  }

Or when there's an error on VS Code side:

// figma/src/ui.tsx line 77
    if (pluginMessage.type === "styled-bricks-nodes") {
      socket.emit(
        "code-generation",
        { files: pluginMessage.files },
        (response) => {

          throw new Error("some error from VS Code") // <- add to simulate error

          if (response.status === "ok") {
            setIsGeneratingCode(false);
          }
        }
      );
    }
  1. The Figma plugin will be stuck at the loading screen
    1891680789484_ pic

Expected behavior
We should handle error gracefully and let users know what went wrong.

Set up Github action to automatically publish VS Code on release

Is your feature request related to a problem? Please describe.
The steps to publish a vs code extension is the same everytime:

  1. vsce publish
  2. bump version

So it's ideal if we could automate these steps to avoid mistakes.

Describe the solution you'd like
Whenever we create a release on Github, we could set up an action to do the above two steps.

Describe alternatives you've considered
n/a

Additional context
n/a

HTML code is not formatted

Describe the bug
When generating HTML code, the output is a string in a single line.

To Reproduce
Steps to reproduce the behavior:

  1. Select any component in Figma.
  2. Choose "HTML" as UI Framework in Figma plugin's settings.
  3. Hit "Generate code"
  4. HTML code in VS Code is not formatted.

Expected behavior
HTML code should be prettified.

Screenshots
n/a

Additional context
n/a

Styles not generated for Figma nodes of type "Instance"

Describe the bug
When generating code for a Figma node of type "INSTANCE", the code does not have any styles.

To Reproduce
Steps to reproduce the behavior:

  1. Go to this Figma file. There are two visually identical nodes, but one is a node of type "instance" and one is a node of type "frame".
  2. Generate code for the instance node.
  3. Live preview in VS Code will look like this:

Screen Shot 2023-04-04 at 3 37 48 PM

Whereas if you generate code for the frame node, the live preview will look good:
Screen Shot 2023-04-04 at 3 38 33 PM

Expected behavior
Styles to be generated for Figma nodes of type "instance".

Software Versions (please fill if applicable):

  • OS: [e.g. macOS 12.2.1]
  • Bricks Figma Plugin: Version 10
  • Bricks VS Code: 0.0.9

Support line nodes in Figma

Is your feature request related to a problem? Please describe.
Lines are often used as dividers in designs. We should also convert it to code. For example:
Screen Shot 2023-05-02 at 2 44 00 PM

Describe the solution you'd like
There are two cases to consider:

  1. If a line separates two pieces of content (i.e. it acts as a thematic break), generate a <hr> element. This is the semantically correct way to implement a divider. MUI also does it this way (reference).
  2. If a line is just by itself (i.e. it acts as decoration), generate a <div> element with a border-width of 1px.

vsce package not working

Describe the bug
Unable to package VS code extension with vsce package

To Reproduce
Run vsce package in vscode directory

Getting this error:

 ERROR  invalid relative path: extension/../.git/COMMIT_EDITMSG

Expected behavior
vsce package should run without error and create a .vsix file.

Screenshots
n/a

Desktop (please complete the following information):

  • OS: macOS 12.2.1

Additional context
n/a

Add support for exporting images

Is your feature request related to a problem? Please describe.
Exporting and rendering images are not supported in the newest version

Design:
Screen Shot 2023-03-27 at 12 21 17 PM

Rendered Component:
Screen Shot 2023-03-27 at 12 21 26 PM

Use Figma's auto layout for positioning if possible

Is your feature request related to a problem? Please describe.
Even though Designers do not always use Figma's auto layout feature. We should use auto layout whenever we can to improve the positioning accuracy of outputted code in Bricks

Add support for multiple styles within a single Figma TextNode

Is your feature request related to a problem? Please describe.
Currently, Bricks can only support a uniform styling of text within a TextNode. However in Figma, you can apply different styles to different sections of the TextNodes. Therefore, we should add support for having multiple styles within a single Figma TextNode

Styles to support:

  • CSS:
    • fontSize
    • fontName
    • fontWeight
    • textDecoration
    • textCase
    • lineHeight
    • letterSpacing
    • fills
    • textStyleId
    • fillStyleId
    • listOptions
    • indentation
    • hyperlink
  • Tailwind CSS
    • fontSize
    • fontName
    • fontWeight
    • textDecoration
    • textCase
    • lineHeight
    • letterSpacing
    • fills
    • textStyleId
    • fillStyleId
    • listOptions
    • indentation
    • hyperlink

Default styles map

If there are multiple text styles within a text node, here are the default styles to use for the outermost <div>:

  • fontSize: font-size: <the font size with the longest length>;
  • fontName: font-family: <the font with the longest length>;
  • fontWeight: font-weight: "normal"; (i.e. Regular font)
  • textDecoration: font-style: "normal";
  • textCase: text-transform: "none";
  • lineHeight: line-height: normal;
  • letterSpacing: letter-spacing: normal;
  • fills: most common blended solid color
  • textStyleId: ?
  • fillStyleId: ?
  • listOptions: ?
  • indentation: ?
  • hyperlink: ?

Inside the <div>, for each different segment of text style, we wrap it in a <span> with the overriding styles.

Todos

  1. Modify getCssAttributes() in core/src/design/adapter/figma/adapter.ts so that it generates default styles if style === figma.mixed. For example:
// font size
if (figmaNode.fontSize !== figma.mixed) {
  attributes["font-size"] = `${figmaNode.fontSize}px`;
} else {
  // add default font size here according to the default styles map above
}
  1. Modify getTextProp() in core/src/code/generator/html/generator.ts so that we generate nested <span>s for each overriding style.

Text is not centered horizontally

Describe the bug

Figma design (Link to Figma component):
Screen Shot 2023-04-18 at 1 55 23 PM

Rendered component:
Screen Shot 2023-04-18 at 1 55 02 PM

Generated code:

import React from "react";
import "./style.css";

const GeneratedComponent = () => (
  <div className="flex flex-row justify-center  pt-4 pr-2.5 pb-4 pl-2.5 rounded w-80 h-14 bg-blue-600">
    <p className="font-body text-xl whitespace-nowrap w-[197px] text-white text-opacity-100 leading-6 font-semibold">
      Request to Book
    </p>
  </div>
);

export default GeneratedComponent;

Allow users to share logs and version number more easily

Is your feature request related to a problem? Please describe.
Currently there is a lot of back and forth when trying to debug an issue with users. I have to ask the user to open the dev console, and to click on VS Code menu to check the extension version.

Describe the solution you'd like
I haven't thought this out thoroughly yet, but whenever there's an error, we could create a log file that contains:

  • Source of error (Figma plugin or VS Code plugin)
  • Stack trace
  • OS version
  • Figma plugin version
  • VS Code plugin version

And we could just ask the user to copy & paste the whole thing and send it to us.

Figma text vertical alignment for fonts do not always work due to the height of the font container

Is your feature request related to a problem? Please describe.
Currently, textNodes in Figma have a property called vertical alignment. When the height of the text container is about the size of the font, vertical alignment such as TOP and BOTTOM is essentially the same as CENTER. However, when Bricks applies the same vertical alignment CSS property, text looks slightly different from the design.

Design:
Screen Shot 2023-03-27 at 10 27 36 AM

Rendered Component:
Screen Shot 2023-03-27 at 10 27 43 AM

Use GPT to name main component

Currently the component name is hardcoded. A quick and easy way to use GPT might be to give it the generated code, then ask it to come up with a name?

// CSS and TW generator
const mainComponentName = "GeneratedComponent";

Add support for Vectors in the new Bricks node

Is your feature request related to a problem? Please describe.
The newer version of Bricks node do not support Vector/Ellipsis Figma nodes in the code generation process.

Describe the solution you'd like
Integrate the new Bricks node with Vector/Ellipsis grouping logic that exists in the previous version of Bricks nodes.

Make inclusion rules more lenient

Designers do not always put their elements perfectly inside its parent. Our tool needs to account for the scenario when 2 percent of their element overflows the parent

Text in generated code is not escaped

Describe the bug

To Reproduce
When the text is {Text}, Bricks will generate code like this:

<p>{Text}</p>

which will result in s blank live preview.

Expected behavior
Text should be escaped and rendered exactly like Figma.

Screenshots
Example of component that will break right now:
Screen Shot 2023-04-18 at 1 49 22 PM

Transparent Figma Frame is being rendered

Is your feature request related to a problem? Please describe.
Transparent Figma frames is being rendered with white backgrounds in generated code.

Desired Design:
Screen Shot 2023-03-23 at 2 55 30 PM
Rendered Components:
Screen Shot 2023-03-23 at 2 55 34 PM

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.