Using multiple Slots within a Component
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 3/5
- Tempo estimado
- 1-2 dias
- Facilidade para iniciantes
- 48/100
- Tipo de issue
- Funcionalidade
- Clareza
- Razoavelmente clara
- Status de atividade
- Estagnada
- Stack de tecnologia
- react, typescript
- Domínio
- developer-experience
Direção de pesquisa
Start with the Code Connect documentation and the implementation of figma.children and figma.instance to determine whether multiple named slots can be mapped independently. The issue provides no source files or tests to begin from, so first identify the relevant API entry points and existing slot tests. Done means documenting or supporting a clear way to connect both content and action slots in one component.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
I'll start by saying that I'm not developer and my knowledge of React and Code Connect has been self taught. I apologize if this can already be done and I'm just missing something...
We have a component where we have multiple Props that we are using Slots for:
<ComponentName
content={}
actions={}
/>
Here's an example of our figma.tsx
import { ComponentName } from '@something';
import figma from `@figma/code-connect`;
const FigmaLink = "..."
const ComponentNameProps = {
content: figma.boolean("Content", {
false: undefined,
true: figma.children('ContentSlot')
}),
action: figma.boolean("Action", {
false: undefined,
true: figma.children('ActionSlot')
})
};
figma.connect(ComponentName, FigmaLink , {
props: {
...ComponentNameProps,
},
example: ({ content, action }) => {
return <ComponentName content={content} action={action} />;
}
});
Note: we separate our Links and Props whenever we use different variant use case examples.
In previous cases where we used Slots, it was set as children with a catchall (figma.children('*')) and this works great. I'm struggling to find a way of implementing the Code Connect for these components without having to create subComponents using the catch all method:
I haven't tested this but this is what I would do in that case:
_ComponentNameContent and _ComponentNameAction:
import { Fragment } from '@something';
import figma from `@figma/code-connect`;
figma.connect(
Fragment,
'...',
{
props: {
children: figma.children('*'),
}.
example: ({ children }) => (
<Fragment>{children}</Fragment>
)
}
)
Then the Code Connect would be:
import { ComponentName } from '@something';
import figma from `@figma/code-connect`;
const FigmaLink = "..."
const ComponentNameProps = {
content: figma.boolean("Content", {
false: undefined,
true: figma.instance('_ComponentNameContent')
}),
action: figma.boolean("Action", {
false: undefined,
true: figma.children('_ComponentNameAction')
})
};
figma.connect(ComponentName, FigmaLink , {
props: {
...ComponentNameProps,
},
example: ({ content, action }) => {
return <ComponentName content={content} action={action} />;
}
});
Sorry if there's some errors, I had to type this all up from my personal computer since I don't have access to GH on my work computer. Does anyone have any thoughts/solutions?
- Linguagem predominante
- TypeScript
- Estrelas
- 1.6k
- Forks
- 126
- Métricas de merge de PRs
- Nenhum PR com merge em 30d
Preparar o ambiente
Este projeto não oferece contêiner de desenvolvimento, Dockerfile nem guia de contribuição, então a configuração fica por sua conta: comece pelo README e veja nosso guia da primeira contribuição para os passos gerais.
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de figma/code-connect
-
normalizePropName strips `#` characters from Figma property names instead of only the `#id` suffixAberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
figma/code-connect#419 ·
-
feature request
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 66/100
figma/code-connect#403 ·
-
feature request
Dificuldade 5/5 Mais de uma semana Facilidade para iniciantes 38/100
figma/code-connect#414 ·
-
feature request
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 48/100
figma/code-connect#413 · 1 comentário ·
-
feature request
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 54/100
figma/code-connect#412 · 1 comentário ·
Todas as issues de figma/code-connect
Issues semelhantes
-
お問い合わせのメール送信に失敗しても成功と表示されるAbertaarea: web
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
inabagumi/shinju-date#6823 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
vercel-labs/ui#540 ·
Mantenedores costumam responder em até 1 dia
-
accepted ai-dev ai-implementing
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 74/100
livesport/homer#218 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
Mantenedores costumam responder em até 1 dia