-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(ButtonGroup): removed material icons dependency
docs(button-group): updated examples
- Loading branch information
Showing
5 changed files
with
133 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<script lang="ts"> | ||
import { BUTTON_GROUP_BUTTON_CONTEXT_ID } from './Button.svelte'; | ||
import { getContext } from 'svelte/internal'; | ||
import { get_current_component } from 'svelte/internal'; | ||
import { forwardEventsBuilder, useActions, type ActionArray } from '../../actions'; | ||
export let use: ActionArray = []; | ||
import { exclude } from '../../utils/exclude'; | ||
const forwardEvents = forwardEventsBuilder(get_current_component()); | ||
const { iconSize }: { iconSize: string } = getContext(BUTTON_GROUP_BUTTON_CONTEXT_ID); | ||
export let data = ''; | ||
export let viewBox = extractViewBox(data); | ||
export let size = iconSize; | ||
export let width = size; | ||
export let height = size; | ||
export let color = 'currentColor'; | ||
export let stroke = color; | ||
export let fill = color; | ||
$: elements = data.replace(/<svg ([^>]*)>/, '').replace('</svg>', ''); | ||
function extractViewBox(svg: string) { | ||
const regex = /viewBox="([\d\- ]+)"/; | ||
const res = regex.exec(svg); | ||
if (!res) return '0 0 24 24'; // default value | ||
return res[1]; | ||
} | ||
</script> | ||
|
||
<svg | ||
xmlns="http://www.w3.org/2000/svg" | ||
{width} | ||
{height} | ||
{viewBox} | ||
{stroke} | ||
{fill} | ||
use:useActions={use} | ||
use:forwardEvents | ||
{...exclude($$props, ['use', 'fill', 'viewBox', 'width', 'height', 'stroke'])} | ||
> | ||
{@html elements} | ||
</svg> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters