Skip to content

Pattern: simplified defintions #472

@techniq

Description

@techniq

In order to support Canvas and simplify common use cases, we should support

<Pattern lines=[{ x2: '100%', class: 'stroke-surface-content' }] width={4} height={4}>
  {#snippet children({ pattern })}
    <rect fill={pattern} />
  {/snippet}
</Pattern>

or

<Pattern shapes=[{ type: 'rect', x2: '100%', class: 'stroke-surface-content' }] width={4} height={4}>
  {#snippet children({ pattern })}
    <rect fill={pattern} />
  {/snippet}
</Pattern>

which translates to:

<Pattern width={4} height={4}>
  {#snippet patternContent()}
    <line x2="100%" class="stroke-surface-content" />
  {/snippet}

  {#snippet children({ pattern })}
    <rect fill={pattern} />
  {/snippet}
</Pattern>

We would support line, circle, and other shape types. Using <Pattern shapes> would allow controlling the render/stack order, but would be a more verbose API as well (commonly you only need a single type, or the shapes do not overlap)

Might also be nice to simplify further, similar to Nivo (source) and Visx (source)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions