Skip to content

Commit

Permalink
feat: component as nested selector
Browse files Browse the repository at this point in the history
  • Loading branch information
drozdzynski committed Dec 8, 2023
1 parent 594d3ef commit 265d2ab
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
20 changes: 20 additions & 0 deletions packages/svelte/stories/ComponentSelector.stories.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<script lang="ts">
import { Meta, Template, Story } from "@storybook/addon-svelte-csf";
import ComponentSelector from "./ComponentSelector.svelte";
</script>

<Meta
title="Svelte/ComponentSelector"
component={ComponentSelector}
argTypes={{
label: { control: "text" },
}}
/>

<Template let:args>
<ComponentSelector {...args} on:click={args.onClick} />
</Template>

<Story
name="Default"
/>
7 changes: 7 additions & 0 deletions packages/svelte/stories/ComponentSelector.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

<script lang="ts">
import { Component, InnerComponent } from './componentSelector'
</script>

<Component>Default component</Component>
<InnerComponent><Component>Same component with color override</Component></InnerComponent>
19 changes: 19 additions & 0 deletions packages/svelte/stories/componentSelector.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { component } from '@teiler/svelte'

const Component = component.div`
color: black;
background: #efefef;
border-radius: 5px;
padding: 10px 12px;
display: inline-block;
`

const InnerComponent = component`
display: inline-block;
& ${Component} {
color: red !important;
}
`

export { Component, InnerComponent }

0 comments on commit 265d2ab

Please sign in to comment.