Comments (7)
My edit was to late, but yes that is what I noticed. The enter key did not register as a click. And we used
button {
all: unset;
}
to remove all the styles....
And this became the ClickableIcon
component:
<button on:click>
<slot />
</button>
<style lang="scss">
button {
all: unset;
display: flex;
align-items: center;
&:focus {
outline: 2px solid var(--cds-focus);
outline-offset: 2 px;
}
}
</style>
from carbon-icons-svelte.
Can you elaborate on the use case?
from carbon-icons-svelte.
Also, forwarded events on:click
etc has also been removed. So now I have do wrap the icons in a div if I want to be able to click on them? Seems like a bad choice
from carbon-icons-svelte.
@Addeuz That should not be done anyway because of accessibility. If something should be clickable, it should be wrapped in a button or link.
from carbon-icons-svelte.
We use icons as buttons when a button is to small. And using a link for a click that isn't navigation is also bad a11y.
We also add a tabindex
to the icon so it can be tapped through. Idk if we can make it any more compliant with a11y. But if someone have tips they are much appreciated.
But now without the on:click
we have to put a div around the icons and put the on:click
and tabindex
on the div
Edit: Further thinking... @brunnerh after some thought I understood what you mean by wrapping it in a button. Not necessarily a carbon button but a "normal" button. So we made a wrapper class that wraps a button around the icon we want and we put the click on the button.
from carbon-icons-svelte.
tabindex
is almost useless, if you do not additionally handle key events, the click handler will not fire on pressing enter/space if the element is not a link/button. Obviously links should only be used for navigation. In addition to being triggered on enter/space the element should also be given role=button
.
All of this is wasted effort, you can just use a regular button
, as intended. "when a button is too small" is thinking about a button as fixed visual concept, all you have to do is style it accordingly. Usually I just add a CSS class that removes all default styling for this purpose, it is way easier than trying to create all the interactivity and accessibility features from scratch.
.bare-button {
background: none;
border: none;
margin: 0;
padding: 0;
font-family: inherit;
font-size: inherit;
}
(This might need additional properties, depending on what other styles you have applied.)
from carbon-icons-svelte.
I will commit to communicating breaking changes more explicitly.
from carbon-icons-svelte.
Related Issues (20)
- Preview website is not working anymore HOT 1
- Package format issue? HOT 2
- TypeScript support for deeply imported Svelte components
- Package crashes npm, yarn, & node several times HOT 3
- Very Much Error in run HOT 2
- Passing v11 icons to components as prop with specific size HOT 6
- It seems the Delete icon has been... deleted ? HOT 2
- import many icons with single import HOT 4
- Error when using icons HOT 1
- messaging apps icon HOT 1
- Use named imports in docs HOT 3
- Package optimizations
- Update contributing guide with release flow HOT 1
- Fix generated `build-info.json` with correct icons and classification
- Viewbox
- Svelte 4 support
- Improve security practices for `carbon-icons-svelte` HOT 1
- Update the Twitter SVG to X SVG HOT 1
- vite-plugin-svelte: missing exports condition HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from carbon-icons-svelte.