Skip to content

Commit

Permalink
Code Connect v1.1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
figma-bot committed Sep 11, 2024
1 parent bc4caf4 commit a7fab93
Show file tree
Hide file tree
Showing 67 changed files with 158 additions and 349 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
# Code Connect v1.1.3 (11th September 2024)

## Fixed

### HTML
- Fixed an issue where `imports` was incorrectly not included in the TypeScript interface
- Added a note in the [documentation](docs/html.md) that HTML support requires `moduleResolution: "NodeNext"`

### React
- Fixed an issue where `imports` was incorrectly not included in the TypeScript interface (fixes https://github.com/figma/code-connect/issues/159)

# Code Connect v1.1.2 (10th September 2024)

## Fixed
Expand Down
6 changes: 3 additions & 3 deletions cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@figma/code-connect",
"version": "1.1.2",
"version": "1.1.3",
"description": "A tool for connecting your design system components in code with your design system in Figma",
"keywords": [],
"author": "Figma",
Expand Down Expand Up @@ -36,7 +36,7 @@
},
"scripts": {
"dev": "tsx src/cli.ts",
"build": "tsc",
"build": "rm -rf dist && npm run typecheck && tsc",
"build:web": "pnpm build",
"build:webpack": "webpack --mode production",
"test": "npm run test:no-coverage -- --coverage",
Expand All @@ -57,7 +57,7 @@
"bundle:cli:mac:arm64": "npm run bundle:cli -- -o bundle-cli/figma-mac-arm64 --target node18-mac-arm64",
"bundle:cli:win": "npm run bundle:cli -- -o bundle-cli/figma-win --target node18-win-x64",
"publish:npm": "npm install && npm run build && npm run bundle:npm-readme:prepare && npm publish --access public; npm run bundle:npm-readme:restore",
"typecheck": "tsc --noEmit"
"typecheck": "tsc --noEmit -p tsconfig-typecheck.json"
},
"devDependencies": {
"@types/cross-spawn": "^6.0.6",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import figma from '../../..'
import figma from '../../../../../react/index_react'

import { ReactApiComponent } from './ReactApiComponent'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { StoryParameters } from '../../..'
import { StoryParameters } from '../../../../../react/index_react'
import { StorybookComponent } from './StorybookComponent'
import React from 'react'

export default {
title: 'StorybookComponent',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ReactNode } from 'react'
import React from 'react'

interface Props {
disabled: boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export default figma.tsx\`<ReactApiComponent />\``,
figmaNode: 'https://figma.com/test',
source:
'https://github.com/figma/code-connect/blob/main/cli/src/connect/__test__/e2e/e2e_parse_command/react_storybook/StorybookComponent.tsx',
sourceLocation: { line: 7 },
sourceLocation: { line: 8 },
templateData: { imports: [] },
component: 'StorybookComponent',
label: 'Storybook',
Expand Down
248 changes: 0 additions & 248 deletions cli/src/connect/__test__/template_rendering_utils.ts

This file was deleted.

9 changes: 6 additions & 3 deletions cli/src/connect/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,10 @@ export interface FigmaConnectLink {
url: string
}

export interface FigmaConnectMeta<T = {}, ExampleFnReturnT = unknown> {
// ExampleFnReturnT is the return type of an example function.
// ExtraExampleT allows us to pass in an extra type to the `example` property,
// so that in Storybook, we can use strings to refer to non-hoisted functions
export interface FigmaConnectMeta<T = {}, ExampleFnReturnT = unknown, ExtraExampleT = never> {
/**
* Restricts this figma connect to any variants that fullfill the given filter.
* The filter is a map of Figma variant names to values. Example:
Expand All @@ -140,7 +143,7 @@ export interface FigmaConnectMeta<T = {}, ExampleFnReturnT = unknown> {

/**
* Prop mappings for the connected component. This is used to map the values of the component's props
* to the values that are used in Figma, using helper functions like `Figma.boolean`. For example:
* to the values that are used in Figma, using helper functions like `figma.boolean`. For example:
* ```ts
* props: {
* disabled: figma.boolean('Disabled'),
Expand All @@ -160,7 +163,7 @@ export interface FigmaConnectMeta<T = {}, ExampleFnReturnT = unknown> {
* @param props
* @returns
*/
example?: (props: T) => ExampleFnReturnT
example?: ((props: T) => ExampleFnReturnT) | ExtraExampleT

/**
* A list of links that will display in Figma along with the examples
Expand Down
6 changes: 6 additions & 0 deletions cli/src/html/__test__/parser/examples/CustomImports.figma.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import figma, { html } from '../../../index_html'

figma.connect('ui/button', {
example: () => html`<my-button>Click me</my-button>`,
imports: ['import "@ui/Button"'],
})
12 changes: 12 additions & 0 deletions cli/src/html/__test__/parser/parser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,16 @@ describe('HTML Parser', () => {
async () => await testParse('RegularFunctionExampleWithExtraCode.figma.ts'),
).rejects.toThrow('Expected only a tagged template literal as the body of the render function')
})

it('handles imports', async () => {
const result = await testParse('CustomImports.figma.ts', [])

expect(result).toMatchObject([
{
templateData: {
imports: ['import "@ui/Button"'],
},
},
])
})
})
7 changes: 2 additions & 5 deletions cli/src/html/external.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { FigmaConnectMeta } from '../connect/api'
import {
booleanType,
enumType,
Expand All @@ -8,11 +7,9 @@ import {
textContentType,
} from '../connect/external_types'
import { HtmlTemplateString } from './template_literal'
import { HtmlMeta } from './types'

function connectType<P = {}>(
_figmaNodeUrl: string,
_meta?: FigmaConnectMeta<P, HtmlTemplateString>,
): void {}
function connectType<P = {}>(_figmaNodeUrl: string, _meta?: HtmlMeta<P>): void {}

function instanceType(_figmaPropName: string): HtmlTemplateString {
return {
Expand Down
Loading

0 comments on commit a7fab93

Please sign in to comment.