This file contains hidden or 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
function sendContrastInfo(contrast, foreground, backgound) { | |
figma.ui.postMessage({ | |
type: 'selectionChange', | |
foreground, | |
background, | |
contrast, | |
}) | |
} |
This file contains hidden or 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
figma.on('selectionchange', () => { | |
if (figma.currentPage.selection.length > 1) { | |
const selection = figma.currentPage.selection.filter( | |
node => node.fills.length > 0 && node.fills[0].type === 'SOLID' | |
) | |
// filter out the first fills of each layer | |
const fills = selection.map(node => node.fills[0]) | |
const contrast = calculateContrast(fills[0].color, fills[1].color) | |
console.log(contrast) | |
} |
This file contains hidden or 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
function calculateLuminance(color) { | |
//just return 1 for now | |
return 1 | |
} | |
function calculateContrast(foreground, background) { | |
console.log(foreground, background) | |
const foregroundLuminance = calculateLuminance(foreground) | |
const backgroundLuminance = calculateLuminance(background) | |
return foregroundLuminance / backgroundLuminance |
This file contains hidden or 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
figma.showUI(__html__) | |
figma.on('selectionchange', () => { | |
if (figma.currentPage.selection.length > 1) { | |
// find nodes with fills that are of type SOLID | |
const selection = figma.currentPage.selection.filter( | |
node => node.fills.length > 0 && node.fills[0].type === 'SOLID' | |
) | |
console.log(selection[0].fills) | |
} else { |
This file contains hidden or 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
var express = require('express') | |
var app = express() | |
const FigmaAPIKey = 'XXXX–XXXXXXXX–XXXX–XXXX-XXXX–XXXXXXXXXXXX' | |
const FigmaFileID = `SoMEGIbBeriSHHerE` | |
app.listen(3001, console.log("Holy shit, I'm a server and I am listening on port 3001")) |
This file contains hidden or 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
var express = require('express') | |
var app = express() | |
app.listen(3001, console.log("Holy shit, I'm a server and I am listening on port 3001")) |
This file contains hidden or 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
var containerStyle = { | |
display: 'flex', | |
alignItems: 'center', | |
justifyContent: 'center', | |
margin: 24, | |
height: '100vh', | |
} | |
var divStyle = { | |
margin: 24, |
This file contains hidden or 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
class App extends Component { | |
state = { images: [ | |
{ name: '', url:'' } | |
]} | |
componentDidMount() {//1 | |
fetch('/frames')//2 | |
.then(res => res.json())//3 | |
.then(data => this.setState({ images: data }))//4 | |
.catch(error => console.log(error)); |
This file contains hidden or 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
class App extends Component { | |
state = { images: [ | |
{ name: '', url:'' } | |
]} | |
render() { | |
return ( | |
<div className="App" > | |
{this.state.images.map( //1 | |
(frame,i) => |
This file contains hidden or 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
class App extends Component { | |
state = { images: [ | |
{ name: '', url:'' } | |
]} | |
render() { | |
return ( | |
); | |
} |