question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Feature] Refer to component by ID instead whole file by ID

See original GitHub issue

It should become possible to refer to a Figma component with the <Figma></Figma> Vue.js component. For instance we have these three Figma components:

image

On each I should be able to use the component name (or a custom id via the figma-low-code plugin). I should then be able to refere to this component like this for example:

Example:

    <Figma :figma="figmaConfig" component="Btn-Single-Sign-On-Google"></Figma>

At the moment I can only refer to the WHOLE file. That is not sufficient since I want to reuse single components. One could now say that Figma components already handles the “reusability” and there is no need to bring this into Vue.js component.

However the idea is to work with that like this: Creating a component only refering to the Figma component not the whole Figma file…

ui/buttons/single-sign-on.vue

<template>
  <div>
    <Figma :figma="figmaConfig" component="Btn-Single-Sign-On-Google" v-model="viewModel"></Figma>
  </div>
</template>

<script>
export default {
  name: 'SingleSignOn',
  data: function () {
    return {
      figmaConfig: {
        figmaFile: '<file-id>',
        figmaAccessKey: '<access-key>'
      },
      viewModel: {
      }
    }
  }
}
</script>

… and the using the Custom component feature of the figma-low-code plugin to refer to this inside another component.

image

And this Button 1 Figma component I can then refer again in a Vue.js component like this:

ui/groups/login.vue

<template>
  <div>
    <Figma :figma="figmaConfig" component="Group-1" v-model="viewModel"></Figma>
  </div>
</template>

<script>
export default {
  name: 'Login',
  data: function () {
    return {
      figmaConfig: {
         figmaFile: '<file-id>',
         figmaAccessKey: '<access-key>'
      },
      viewModel: {
      }
    }
  }
}
</script>

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:15 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
KlausSchaefersAtWorkcommented, Nov 9, 2020

Hi, the first version of the design system is ready to try:

https://github.com/KlausSchaefers/vue-low-code#Designlet-Mode

The documentation is for Quant-UX but for Figma it works basically the same. Please note that I only import elements (components or not) that are direct children of a root artboard.

  1. First you have to register your deisgn
import Vue from 'vue'
import App from './App.vue'
import './registerServiceWorker'
import router from './router'
import * as VueLowCode from 'vue-low-code'
import figmaDesign from './views/figma-design-system.json'
import quxDesign from './views/qux-design-system.json'

Vue.config.productionTip = false

/*
 * Make sure the design is registered before the App is mounted
 */
async function init () {
    // for live debuging use Figma.createFigmaDesignlets(<FileID>, <AccessKey>)
  await VueLowCode.createFigmaDesignlets(figmaDesign)
  // for live debuging use Figma.createFigmaDesignlets(<sharekey>)
  await VueLowCode.createQUXDesignlets(quxDesign)

  new Vue({
    router,
    render: h => h(App)
  }).$mount('#app')
}

init()
  1. Now you can use them as Tags <MyButton /> <MyButton>Hello World</MyButton>

Thanks again for the idea! All feedback is welcome!

1reaction
xetra11commented, Oct 22, 2020

oh exciting! Will take a look in a few! Can you link the commits here so I might take a look how you managed to do it?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Document.getElementById() - Web APIs | MDN
Because ID values must be unique throughout the entire document, there is no need for "local" versions of the function. Example. <!DOCTYPE html> ......
Read more >
JavaScript and getElementById for multiple elements with the ...
If you have several elements with the same ID, your HTML is not valid. So, document.getElementById should only ever return one element.
Read more >
Lesson 1: Understanding ID and Class in CSS
In HTML, every element on your web page can be assigned a unique id attribute. This can be any text you like, but...
Read more >
How To Select HTML Elements Using ID, Class, and Attribute ...
The id attribute is a unique identifier that links together content on the page. For example, say there is an element midway down...
Read more >
Searching: getElement*, querySelector*
Here in the tutorial we use id to directly reference an element for brevity, ... object. It looks for the given id in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found