-
-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added usage comment functionality to core package * Added usage comment to the generated code * docs(changeset): Added usage comment prefix * Updated changeset workflow * Added ignore paths * Updated ignore glob * Removed test commands from figma package * Disabled fail on error
- Loading branch information
1 parent
0ec8a29
commit 640c289
Showing
11 changed files
with
175 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"svg-to-swiftui-core": patch | ||
"figma-to-swiftui": patch | ||
--- | ||
|
||
Added usage comment prefix |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Figma to SwiftUI Converter | ||
|
||
## Overview | ||
|
||
This plugin lets you export paths from Figma to SwiftUI Shape structure. | ||
|
||
## How to use | ||
|
||
- Select the vector object that you want to convert. | ||
- Make sure you **select the specific vector path** that you want to convert. | ||
- Open Figma DEV mode. | ||
- Select SwiftUI Code Generator from the language export options. | ||
- Copy code and paste it into your SwiftUI project! | ||
|
||
## Links | ||
|
||
- Visit Web App version of this converter [here](https://dub.sh/svg-to-swiftui). | ||
- Need help with developing your designs? Visit my development agency [Quassum](https://dub.sh/quassum)! | ||
- Made by [Antoni](https://dub.sh/antoni) | ||
|
||
## Community | ||
|
||
Wanna suggest some changes or just to say hi? Join our community here: | ||
|
||
- [Github Discussions](https://github.com/quassum/SVG-to-SwiftUI/discussions) | ||
- [Quassum Discord](https://discord.gg/VzpZ7np622) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import {SwiftUIGeneratorConfig, ViewBoxData} from './types'; | ||
|
||
export const createUsageCommentTemplate = ({ | ||
config, | ||
viewBox, | ||
}: { | ||
config: SwiftUIGeneratorConfig; | ||
viewBox: ViewBoxData; | ||
}) => [ | ||
'// To use this shape, just add it to your SwiftUI View:', | ||
`// ${config.structName}().fill().frame(width: ${viewBox.width}, height: ${viewBox.height})`, | ||
]; | ||
|
||
type ParameterName = string; | ||
type ParameterType = string; | ||
|
||
const indentStrings = ({indent, body}: {indent: number; body: string[]}) => { | ||
return body.map(row => `${new Array(indent).fill(' ').join('')}${row}`); | ||
}; | ||
|
||
const parametersToStrings = (parameters: [ParameterName, ParameterType][]) => { | ||
return parameters.map(([name, type]) => `${name}: ${type}`).join(', '); | ||
}; | ||
|
||
export const createFunctionTemplate = ({ | ||
name, | ||
parameters, | ||
returnType, | ||
body, | ||
indent = 4, | ||
}: { | ||
name: string; | ||
parameters: [ParameterName, ParameterType][]; | ||
returnType: string; | ||
body: string[]; | ||
indent?: number; | ||
}) => { | ||
const parametersString = parametersToStrings(parameters); | ||
|
||
return [ | ||
`func ${name}(${parametersString}) -> ${returnType} {`, | ||
...indentStrings({body, indent}), | ||
`}`, | ||
]; | ||
}; | ||
|
||
export const createStructTemplate = ({ | ||
name, | ||
returnType, | ||
body, | ||
indent = 4, | ||
}: { | ||
name: string; | ||
returnType: string; | ||
body: string[]; | ||
indent?: number; | ||
}) => { | ||
return [ | ||
`struct ${name}: ${returnType} {`, | ||
...indentStrings({body, indent}), | ||
`}`, | ||
]; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters