🇺🇸 English 🌟 Help us by starring the project! 🌟
🇧🇷 Português 🌟 Ajude-nos dando uma estrela ao projeto! 🌟
Para iniciar o desenvolvimento do plugin, instale as dependências do projeto e, em seguida, execute o comando watch
:
$ npm install
$ npm run watch
ou
$ yarn
$ yarn watch
Importar plugin a partir do manifesto…
via barra de pesquisa ou pelo menu.manifest.json
gerado pelo script build
na raiz do projeto.Mostrar/Ocultar Console
via a barra de pesquisa ou Ações Rápidas. Utilize console.log()
para debug do plugin.. │./package.json │./tsconfig.json │./tailwind.config.js │./manifest.json │./src/ ├── main.ts ├── ui.tsx ├── components/ │ ├── flex-container.tsx │ └── label.tsx ├── css/ │ └── input.css ├── pages/ │ └── deafault.tsx └── types/ └── size.ts
Todas as alterações no projeto devem ser realizadas na pasta src
, exceto o nome
e id
que são alterados dentro de package.json
na raiz do projeto.
voltar para estrutura do projeto
Na raiz do projeto, temos o arquivo package.json responsável por gerenciar o plugin e seus arquivos. Na seção figma-plugin
pode ser configurado:
id
: Código de referência do seu plugin dentro do Figma. Código gerado durante a publicação do plugin.
name
: Nome que será exibido na janela de plugins.
voltar para estrutura do projeto
Arquivo de configuração do TypeScript.
voltar para estrutura do projeto
Arquivo de configuração do Tailwind CSS.
voltar para estrutura do projeto
Arquivo gerado pelo build do plugin. Este é o arquivo que deve ser importado pelo Figma.
voltar para estrutura do projeto
Arquivo responsável por executar o comando showUI()
e configurar em pixels a width
e height
da janela do plugin.
import { showUI } from "@create-figma-plugin/utilities";
export default function () {
showUI({
height: 240,
width: 240,
});
}
voltar para estrutura do projeto
Principal arquivo para renderização das telas do plugin. A função GetPage
é responsável por realizar a troca de páginas do plugin e a injeção da função de troca de tela.
export default render(() => {
const [pageTitle, setPageTitle] = useState<PagesName>("Home Page");
function GetPage({ title }: { title: PagesName }): JSX.Element {
switch (title) {
case "Home Page":
return <DefaultPage setPageTitle={setPageTitle} />;
case "Page 2":
return <OtherPage setPageTitle={setPageTitle} />;
default:
return <DefaultPage setPageTitle={setPageTitle} />;
}
}
return <GetPage title={pageTitle} />;
});
Para finalização do plugin, execute o comando build
para a construção (automática) do arquivo manifest.json
e o diretório build/
contendo o JavaScript do plugin.
$ yarn build
To start developing the plugin, install project dependencies and then run the watch
command:
$ npm install
$ npm run watch
or
$ yarn
$ yarn watch
Import plugin from manifest...
via the search bar or the menu.manifest.json
file generated by the build
script at the project's root.Show/Hide Console
option via the search bar or Quick Actions. Use console.log()
for plugin debugging.. │./package.json │./tsconfig.json │./tailwind.config.js │./manifest.json │./src/ ├── main.ts ├── ui.tsx ├── components/ │ ├── flex-container.tsx │ └── label.tsx ├── css/ │ └── input.css ├── pages/ │ └── deafault.tsx └── types/ └── size.ts
All project changes should be made in the src
folder, except for the name
and id
which are changed within package.json
at the project's root.
At the project's root, we have the package.json file responsible for managing the plugin and its files. In the figma-plugin
section, you can configure:
id
: Reference code for your plugin within Figma. Code generated during the plugin's publication.
name
: Name that will be displayed in the plugins window.
TypeScript configuration file.
Tailwind CSS configuration file.
File generated by the plugin's build. This is the file to be imported by Figma.
File responsible for executing the showUI()
command and configuring the width
and height
of the plugin window in pixels.
import { showUI } from "@create-figma-plugin/utilities";
export default function () {
showUI({
height: 240,
width: 240,
});
}
Main file for rendering the plugin's screens. The GetPage
function is responsible for switching plugin pages and injecting the screen-switching function.
export default render(() => {
const [pageTitle, setPageTitle] = useState<PagesName>("Home Page");
function GetPage({ title }: { title: PagesName }): JSX.Element {
switch (title) {
case "Home Page":
return <DefaultPage setPageTitle={setPageTitle} />;
case "Page 2":
return <OtherPage setPageTitle={setPageTitle} />;
default:
return <DefaultPage setPageTitle={setPageTitle} />;
}
}
return <GetPage title={pageTitle} />;
});
To finalize the plugin, run the build
command to automatically build the manifest.json
file and the build/
directory containing the plugin's JavaScript.
$ yarn build