Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: figma button #5

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/_includes/default.njk
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
<script src="{{ assetUrl('scripts/code-previews.js') }}" defer></script>
<script src="{{ assetUrl('scripts/lunr.js') }}" defer></script>
<script src="{{ assetUrl('scripts/search.js') }}" defer></script>
<script src="{{ assetUrl('scripts/figma-button.js') }}" defer></script>
</head>
<body>
<a id="skip-to-main" class="visually-hidden" href="#main-content" data-smooth-link="false">
Expand Down Expand Up @@ -80,6 +81,11 @@
<sl-icon name="twitter"></sl-icon>
</a>

{# Figma #}
<a href="#" title="Connection to Figma" data-figma-button>
<sl-icon library="system" name="figma-mono"></sl-icon>
</a>

{# Theme selector #}
<sl-dropdown id="theme-selector" placement="bottom-end" distance="3">
<sl-button slot="trigger" size="small" variant="text" caret title="Press \ to toggle">
Expand Down
24 changes: 24 additions & 0 deletions docs/assets/scripts/figma-button.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
window.addEventListener('load', function (event) {
console.log('on load - Figma button, document is ', document.readyState);

var figmaButton = document.querySelector('[data-figma-button]');

if (figmaButton) {
console.log('figma button found', figmaButton.dataset);

figmaButton.onclick = function () {
let status = figmaButton.dataset.figmaButton;
let icon = figmaButton.querySelector('sl-icon');

console.log('figma button clicked with status', status);

if (status === 'on') {
figmaButton.dataset.figmaButton = 'off';
icon.name = 'figma-mono';
} else {
figmaButton.dataset.figmaButton = 'on';
icon.name = 'figma';
}
};
}
});
6 changes: 6 additions & 0 deletions src/components/icon/library.system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,12 @@ const icons = {
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-x-circle-fill" viewBox="0 0 16 16">
<path d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0zM5.354 4.646a.5.5 0 1 0-.708.708L7.293 8l-2.647 2.646a.5.5 0 0 0 .708.708L8 8.707l2.646 2.647a.5.5 0 0 0 .708-.708L8.707 8l2.647-2.646a.5.5 0 0 0-.708-.708L8 7.293 5.354 4.646z"></path>
</svg>
`,
figma: `
<svg id="Layer_1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 200 300" width="1667" height="2500"><style type="text/css">.st0{fill:#0acf83}.st1{fill:#a259ff}.st2{fill:#f24e1e}.st3{fill:#ff7262}.st4{fill:#1abcfe}</style><title>Figma.logo</title><desc>Created using Figma</desc><path id="path0_fill" class="st0" d="M50 300c27.6 0 50-22.4 50-50v-50H50c-27.6 0-50 22.4-50 50s22.4 50 50 50z"/><path id="path1_fill" class="st1" d="M0 150c0-27.6 22.4-50 50-50h50v100H50c-27.6 0-50-22.4-50-50z"/><path id="path1_fill_1_" class="st2" d="M0 50C0 22.4 22.4 0 50 0h50v100H50C22.4 100 0 77.6 0 50z"/><path id="path2_fill" class="st3" d="M100 0h50c27.6 0 50 22.4 50 50s-22.4 50-50 50h-50V0z"/><path id="path3_fill" class="st4" d="M200 150c0 27.6-22.4 50-50 50s-50-22.4-50-50 22.4-50 50-50 50 22.4 50 50z"/></svg>
`,
'figma-mono': `
<svg viewBox="0.5 0.5 171.1 246" xmlns="http://www.w3.org/2000/svg" width="1737" height="2500" fill="currentColor"><path d="M150.7 85c12.5-8.2 20.8-22.4 20.8-38.5 0-25.4-20.7-46-46-46h-79C21.1.5.5 21.2.5 46.5.5 62.6 8.8 76.8 21.3 85 8.8 93.2.5 107.4.5 123.5s8.3 30.3 20.8 38.5C8.8 170.2.5 184.4.5 200.5c0 25.4 20.8 46 46.3 46 25.8 0 46.8-20.9 46.8-46.5v-42.5c8.2 7.4 19.1 12 31 12h1c25.4 0 46-20.7 46-46-.1-16.1-8.4-30.3-20.9-38.5zM78.5 200c0 17.3-14.2 31.5-31.7 31.5-17.2 0-31.2-13.9-31.2-31s13.9-30.9 30.9-31h32zm0-45.5h-32c-17.1 0-30.9-13.9-30.9-31s13.9-31 31-31h32v62zm0-77h-32c-17.1 0-31-13.9-31-31s13.9-31 31-31h32zm15-62h32c17.1 0 31 13.9 31 31s-13.9 31-31 31h-32zm32 139h-1c-17.1 0-31-13.9-31-31s13.9-31 31-31h1c17.1 0 31 13.9 31 31s-13.9 31-31 31z"/></svg>
`
};

Expand Down