(・谷・)<下記はセミナースライド用のダミーだよ
/* モジュールのヘッダ部分(タイトルやメタ情報)にあたるもの */
xxx__head {...}
| const jsonUrl = "https://YOUR_JSON/"; | |
| // 下記のような構造のJSONを返すものを用意すると実行できる | |
| // https://jsonbin.io/ | |
| // | |
| // [ | |
| // { | |
| // "image": "https://image.example.com/xxx.jpg", | |
| // "title": "犬のしつけを成功させる5つの秘訣", | |
| // "description": "犬のしつけは飼い主の一貫した努力が重要です。この記事では、初心者でも簡単に始められるしつけ方法を5つのステップに分けて詳しく解説します。", |
| const API_URL = "https://dog.ceo/api/breeds/image/random"; // 犬画像API | |
| // 選択された要素を取得 | |
| const selection = figma.currentPage.selection; | |
| if (selection.length === 0) { | |
| figma.notify("少なくとも1つのRectangleを選択してください。"); | |
| } else { | |
| const processNode = (node, delay) => { | |
| if (node.type === "RECTANGLE") { |
| // https://www.figma.com/plugin-docs/api/properties/global-fetch/ | |
| // https://www.figma.com/developers/api#post-comments-endpoint | |
| const token = "YOUR_PERSONAL_ACCESS_TOKEN"; // トークンを設定 | |
| const fileKey = "FILE_KEY"; // 対象ファイルのキーを設定 | |
| const message = "Hello, this is a comment for the selected layer."; // コメント内容 | |
| const selection = figma.currentPage.selection; | |
| if (selection.length === 0) { |
| const selection = figma.currentPage.selection[0]; // 最初の選択オブジェクト | |
| if (selection && selection.type === "FRAME") { | |
| const textNodes = selection.findAll((node) => node.type === "TEXT"); | |
| textNodes.forEach(async (textNode) => { | |
| await figma.loadFontAsync(textNode.fontName); // フォントをロード | |
| textNode.fontSize *= 2; // フォントサイズを200%に | |
| }); |
| const selection = figma.currentPage.selection[0]; // 最初の選択オブジェクト | |
| if (selection && selection.type === "FRAME") { | |
| const colors = new Set(); // 色の重複を防ぐ | |
| const children = selection.findAll((node) => "fills" in node); | |
| children.forEach((node) => { | |
| if (Array.isArray(node.fills)) { | |
| node.fills.forEach((fill) => { | |
| if (fill.type === "SOLID") { |
| const colors = [ | |
| figma.util.rgb("#bbf7d0"), | |
| figma.util.rgb("#86efac"), | |
| figma.util.rgb("#4ade80"), | |
| figma.util.rgb("#22c55e"), | |
| figma.util.rgb("#16a34a"), | |
| ]; | |
| const rectangleWidth = 100; // 矩形の幅 | |
| const rectangleHeight = 100; // 矩形の高さ |
| function hasRoundedCorners(r) { | |
| const result = figma.currentPage.findAll(n => n.cornerRadius === r) | |
| figma.currentPage.selection = result | |
| } | |
| // 引数に任意のnumber | |
| hasRoundedCorners(8); |
A Pen by Hiroki Tani on CodePen.
| <link rel="import" href="../components/polymer/polymer.html"> | |
| <polymer-element name="my-element"> | |
| <template> | |
| <style> | |
| :host { | |
| position: absolute; | |
| width: 100%; | |
| height: 100%; |