The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.
Hello! In this vignette, I will show you a basic example of how you
could use the data from the Figma API, to produce custom CSS code, which
you could use it in a design product, such as a website. First, lets
import the package. After that, the quarto_website
object
will be available for you like this:
library(figma)
quarto_website
Response [https://api.figma.com/v1/files/Y7jJJ5KHcG7hjuZVeRPZWq]
Date: 2022-12-08 11:56
Status: 200
Content-Type: application/json; charset=utf-8
Size: 11.5 kB
{"document":{"id":"0:0","name":"Document","type":"DOCUMENT","scrollBehavior":"SCROLLS"...
quarto_website
objectThe quarto_website
object is a response
object produced by figma::get_figma_file()
, so, it contains
all data from a Figma file. In this Figma file, I have drawn a homepage
for a Quarto Website. Below we have a
screenshot of this Figma file:
For now, this response
object is in a format which is
hard to work with. So lets transform it into a more useful format.
First, lets convert it to a figma_document
object with
figma::as_figma_document()
, to get a better structure of
the Figma file. We can see in the result below, that this Figma file
have only one canvas/page, with 11 objects drawn in it:
<- figma::as_figma_document(quarto_website)
fd
fd#> <Figma Document>
#>
#> * Number of canvas: 1
#> * Number of objects in each canvas: 11
Because of that, I will separate all objects from this page into a separate object, like this:
<- fd$canvas[[1]][["objects"]]
objects length(objects)
#> [1] 11
Now, objects
stores all the data from these 11 objects
drawn in this Figma file. As an example, we can see the name attribute
of the first object drawn in the canvas, like this:
1]][["name"]]
objects[[#> [1] "quarto-container"
The data from the Figma API, allows us to build a bridge between visual feedback (i.e. the design) and code output (i.e. the necessary code to build such design). This example might be limited, but can be very useful for analysts that want to make a better connection between their design and developers team, to deliver products faster.
These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.