-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
946 additions
and
28 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
@@ -1,15 +1,239 @@ | ||
import { once, showUI } from '@create-figma-plugin/utilities' | ||
import { CancelHandler, GenerateHandler } from './types' | ||
import { CancelHandler, GenerateHandler, InputValues } from './types' | ||
import { | ||
hexToHSL, | ||
Padding, | ||
generateHues, | ||
generateTints, | ||
generateShades, | ||
Container, | ||
selectFrame, | ||
} from './utils' | ||
|
||
export default function () { | ||
once<GenerateHandler>('GENERATE', function () { | ||
figma.closePlugin('Generate logic') | ||
once<GenerateHandler>('GENERATE', function (inputValues: InputValues) { | ||
const circleSize = 120 | ||
const circleSpace = 30 | ||
const frameDirection = 'HORIZONTAL' | ||
|
||
const { | ||
colorCode, | ||
hue, | ||
hueInterval, | ||
tintForHue, | ||
tintForHueInterval, | ||
shadeForHue, | ||
shadeForHueInterval, | ||
tint, | ||
tintInterval, | ||
shade, | ||
shadeInterval, | ||
} = inputValues | ||
|
||
const color = hexToHSL(colorCode) | ||
|
||
const framePadding: Padding = { | ||
top: 50, | ||
right: 50, | ||
bottom: 50, | ||
left: 50, | ||
} | ||
|
||
if (hue && tint && shade) { | ||
const hues = generateHues( | ||
color, | ||
hueInterval, | ||
frameDirection, | ||
framePadding, | ||
circleSpace, | ||
circleSize, | ||
tintForHue, | ||
shadeForHue, | ||
tintForHueInterval, | ||
shadeForHueInterval | ||
) | ||
const tints = generateTints( | ||
color, | ||
tintInterval, | ||
frameDirection, | ||
framePadding, | ||
circleSpace, | ||
circleSize | ||
) | ||
|
||
const shades = generateShades( | ||
color, | ||
shadeInterval, | ||
frameDirection, | ||
framePadding, | ||
circleSpace, | ||
circleSize | ||
) | ||
|
||
const parentFrame = new Container( | ||
`Parent Frame`, | ||
frameDirection, | ||
framePadding, | ||
70, | ||
'AUTO', | ||
'AUTO' | ||
).createContainer() | ||
|
||
parentFrame.appendChild(hues) | ||
parentFrame.appendChild(tints) | ||
parentFrame.appendChild(shades) | ||
selectFrame(parentFrame) | ||
figma.closePlugin('Hues, tints and shades generated') | ||
} else if (hue && tint) { | ||
const hues = generateHues( | ||
color, | ||
hueInterval, | ||
frameDirection, | ||
framePadding, | ||
circleSpace, | ||
circleSize, | ||
tintForHue, | ||
shadeForHue, | ||
tintForHueInterval, | ||
shadeForHueInterval | ||
) | ||
const tints = generateTints( | ||
color, | ||
tintInterval, | ||
frameDirection, | ||
framePadding, | ||
circleSpace, | ||
circleSize | ||
) | ||
|
||
const parentFrame = new Container( | ||
`Parent Frame`, | ||
frameDirection, | ||
framePadding, | ||
70, | ||
'AUTO', | ||
'AUTO' | ||
).createContainer() | ||
|
||
parentFrame.appendChild(hues) | ||
parentFrame.appendChild(tints) | ||
selectFrame(parentFrame) | ||
figma.closePlugin('Hues and tints generated') | ||
} else if (hue && shade) { | ||
const hues = generateHues( | ||
color, | ||
hueInterval, | ||
frameDirection, | ||
framePadding, | ||
circleSpace, | ||
circleSize, | ||
tintForHue, | ||
shadeForHue, | ||
tintForHueInterval, | ||
shadeForHueInterval | ||
) | ||
|
||
const shades = generateShades( | ||
color, | ||
shadeInterval, | ||
frameDirection, | ||
framePadding, | ||
circleSpace, | ||
circleSize | ||
) | ||
|
||
const parentFrame = new Container( | ||
`Parent Frame`, | ||
frameDirection, | ||
framePadding, | ||
70, | ||
'AUTO', | ||
'AUTO' | ||
).createContainer() | ||
|
||
parentFrame.appendChild(hues) | ||
parentFrame.appendChild(shades) | ||
selectFrame(parentFrame) | ||
figma.closePlugin('Hues and shades generated') | ||
} else if (tint && shade) { | ||
const tints = generateTints( | ||
color, | ||
tintInterval, | ||
frameDirection, | ||
framePadding, | ||
circleSpace, | ||
circleSize | ||
) | ||
|
||
const shades = generateShades( | ||
color, | ||
shadeInterval, | ||
frameDirection, | ||
framePadding, | ||
circleSpace, | ||
circleSize | ||
) | ||
|
||
const parentFrame = new Container( | ||
`Parent Frame`, | ||
frameDirection, | ||
framePadding, | ||
70, | ||
'AUTO', | ||
'AUTO' | ||
).createContainer() | ||
|
||
parentFrame.appendChild(tints) | ||
parentFrame.appendChild(shades) | ||
selectFrame(parentFrame) | ||
figma.closePlugin('Tints and shades generated') | ||
} else if (hue) { | ||
const hues = generateHues( | ||
color, | ||
hueInterval, | ||
frameDirection, | ||
framePadding, | ||
circleSpace, | ||
circleSize, | ||
tintForHue, | ||
shadeForHue, | ||
tintForHueInterval, | ||
shadeForHueInterval | ||
) | ||
selectFrame(hues) | ||
figma.closePlugin('Hues generated') | ||
} else if (tint) { | ||
const tints = generateTints( | ||
color, | ||
tintInterval, | ||
frameDirection, | ||
framePadding, | ||
circleSpace, | ||
circleSize | ||
) | ||
selectFrame(tints) | ||
figma.closePlugin('Tints generated') | ||
} else if (shade) { | ||
const shades = generateShades( | ||
color, | ||
shadeInterval, | ||
frameDirection, | ||
framePadding, | ||
circleSpace, | ||
circleSize | ||
) | ||
|
||
selectFrame(shades) | ||
figma.closePlugin('Shades generated') | ||
} else { | ||
figma.closePlugin('No option selected') | ||
} | ||
}) | ||
once<CancelHandler>('CANCEL', function () { | ||
figma.closePlugin('Close logic') | ||
figma.closePlugin('okay, bye ✌🏾') | ||
}) | ||
showUI({ | ||
width: 400, | ||
height: 537, | ||
height: 335, | ||
}) | ||
} |
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
Oops, something went wrong.