Comments (3)
What are your thoughts on a possible union $$Props type for the button @AdrianGonz97 ?
@huntabyte Totally. We can discriminate on the href
and have something like this:
type Props = {
class?: string | null;
variant?: VariantProps<typeof buttonVariants>["variant"];
size?: VariantProps<typeof buttonVariants>["size"];
};
interface AnchorElement extends Props, HTMLAnchorAttributes {
href?: HTMLAnchorAttributes["href"];
type?: never;
}
interface ButtonElement extends Props, HTMLButtonAttributes {
type?: HTMLButtonAttributes["type"];
href?: never;
}
type $$Props = AnchorElement | ButtonElement;
Autocomplete for data-sveltekit-preload-data
and all that fun stuff should work then. It also has the added bonus of yelling at the user if they specify both an href
and a type
.
from shadcn-svelte.
It's working.
It's just that we don't have auto-complete as VSCode doesn't know "Button" and this attribute.
Maybe you could make it explicit?
If you feel that it's not the right thing to do, feel free to close the ticket 👍
from shadcn-svelte.
The issue I was running into with that was due to the button being able to act as a link OR a button, each of which have their own props.
Let me look into a union type or possible splitting <a>
tags into their own component, something I don't really want to do unless it's a dealbreaker for the community.
What are your thoughts on a possible union $$Props type for the button @AdrianGonz97 ?
from shadcn-svelte.
Related Issues (20)
- Tab component missing defaultValue prop HOT 1
- Adding system agnostic dark mode without js HOT 3
- feat: --nodep or similar flag for init CLI command HOT 5
- Vaul Svelte Link Broken
- Broken links due to directory renaming from apps/www/** to sites/docs/** HOT 2
- Add Time-line (Vertical, Horizontal) HOT 2
- Wrong line highlighted in Data Table Documentations HOT 2
- Specify @internationalized/date version when installing Calendar components
- Data Table - a combination of Pagination and Sort removes the sort property from the props object HOT 1
- #1203 Breaks paths to component source HOT 5
- Wrong Home and Line Chart icons in Blocks Dashboards
- Drawer Overlay receives an unexpected slot HOT 4
- When using TypeScript, path generated still use JavaScript HOT 2
- Checkbox: peer-checked doesn't work HOT 3
- Dialog and dropdown-menu: dialog replaces dropdown-menu on pressing esc button
- Cannot programmatically change values for things like tabs or dialogs HOT 2
- <Input type="file"> does not support bind:files HOT 1
- Tabs Like in the showcase website HOT 4
- Sonner applies dark-mode (system default?) even when not installed/used HOT 2
- Radiogroup item unselectable after removing from dynamic list HOT 2
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 shadcn-svelte.