Break out the SearchInput from the Table component so it can be used independently

This commit is contained in:
palewire 2023-05-26 16:17:36 -04:00
parent fbbf500cbf
commit dcae3ce76c
No known key found for this signature in database
GPG key ID: A5AD4A9AD42D69AB
7 changed files with 50 additions and 2 deletions

View file

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View file

@ -0,0 +1,25 @@
<script>
import { Meta, Template, Story } from '@storybook/addon-svelte-csf';
// Don't lose the "?raw" in markdown imports!
// @ts-ignore
import componentDocs from './stories/docs/component.md?raw';
import SearchInput from './SearchInput.svelte';
import { withComponentDocs } from '$docs/utils/withParams.js';
const meta = {
title: 'Components/SearchInput',
component: SearchInput,
...withComponentDocs(componentDocs),
};
</script>
<Meta {...meta} />
<Template let:args>
<SearchInput {...args} />
</Template>
<Story name="Default" args="{{}}" />

View file

@ -1,3 +1,4 @@
<!-- @component `SearchInput` [Read the docs.](https://reuters-graphics.github.io/graphics-components/?path=/docs/components-SearchInput--default) -->
<script lang="ts">
import { createEventDispatcher } from 'svelte';
import MagnifyingGlass from './MagnifyingGlass.svelte';

View file

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

View file

@ -0,0 +1,22 @@
> **Welcome to your new component!** Use this template to build your component and customise its storybook.
- Build your component in `SearchInput/SearchInput.svelte`.
- Write your component's storybook in `SearchInput/SearchInput.stories.svelte`.
- Don't forget to add your component to `src/index.js`:
```javascript
// ...
export { default as SearchInput } from './components/SearchInput/SearchInput.svelte';
```
- Commit your component to a new branch and push it to GitHub! 🏁
---
```svelte
<script>
import { SearchInput } from '@reuters-graphics/graphics-components';
</script>
<SearchInput />
```

Binary file not shown.

View file

@ -135,7 +135,7 @@
/** Import local helpers */
import Block from '../Block/Block.svelte';
import Pagination from './Pagination.svelte';
import Search from './Search.svelte';
import SearchInput from '../SearchInput/SearchInput.svelte';
import Select from './Select.svelte';
import SortArrow from './SortArrow.svelte';
import { filterArray, paginateArray, getOptions } from './utils.js';
@ -236,7 +236,7 @@
{/if}
{#if searchable}
<div class="table--header--search">
<Search
<SearchInput
bind:searchPlaceholder
on:search="{handleSearchInput}"
/>