Comments (2)
Some interesting gotchas with using SVG with an <img>
tag, you can't style the interior contents of the SVG this way!
https://css-tricks.com/using-svg/
The problem with both img and background-image…
Is that you don’t get to control the innards of the SVG with CSS like you can with the following two ways. Read on!
I have no idea how I didn't already know this, probably one of those things I've learned but forgot. However, this means the idea of using that method kind of goes out the window.
from skeleton.
So I came up with a great solution for handling SVGs that I think bridges the best ideas from both Nik and myself.
The notable changes include:
- I've introduced a new standardized component called
SvgIcon
:
https://github.com/Brain-Bones/skeleton/blob/dev/src/lib/SvgIcon/SvgIcon.svelte - I've bundled all SVG path data into a single definition file called
icons.ts
:
https://github.com/Brain-Bones/skeleton/blob/dev/src/lib/SvgIcon/icons.ts - I've updated all instances of SVG icons throughout the project to utilize this new component.
The combines Nik's idea of leaning into a Svelte component, plus my idea of documenting in a single file, while creating a brand new component that follows the Skeleton conventions for props, including passthrough attributes, Tailwind styles, generic styles, and A11y support. Plus icon.ts
allows us to add the missing Font Awesome attribution.
Additionally, this can still be used with standard SVG child content - you just drop any any code that would normally live between the <svg>...</svg>
tags in as the default slot value.
I've documented the component here:
https://github.com/Brain-Bones/skeleton/blob/dev/src/routes/components/svg-icons/%2Bpage.svelte
Though please note this doc page is currently hidden from the nav bar. I would like to dogfood the component for a bit before we release it to the public. The biggest drawback is the canned set of icons are pretty limited (just what we use in components and docs). However, the ability to build your own is pretty nice. The fact the component comes with default sizes and styling is really nice. Plus there's a default icon shown if you don't provide a name or slot value.
This has been merged into dev
if you would like to test it yourselves.
from skeleton.
Related Issues (20)
- v2 Avatar Additions
- v2 Stackblitz dependency updates HOT 1
- Add style prop to TreeViewItem to allow control of content's width HOT 3
- Resolve a11y warnings in multiple components HOT 3
- Chore: Update LICENSE year
- Skeleton v2 migration to Svelte 5 HOT 3
- LightSwitch breaks in multiple tabs HOT 3
- Migrate the v2 docs to Svelte 4 and SvelteKit v2
- Fix onMount import on the Chat block docs
- Svelte v5 RC: TreeView component is non-function HOT 1
- Svelte v5 RC: Theme Generator live previews are non-functional HOT 1
- Why Paginator pagging component is theme inverted? HOT 4
- Fast hover breaks popup HOT 1
- Autocomplete: input should be of type string. HOT 2
- Finalize v3 installation instructions for all meta-frameworks
- Autocomplete 'on:selection' Event never triggers when inside of a Modal HOT 4
- TypeError: mediaQueryList is not a function.
- NEXT Document minimum versions for all dependencies and supported platforms
- Old LightSwitch component link in Dark Mode section of Essentials/Themes
- Additional a11y warnings to resolve
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 skeleton.