Skip to content

Commit

Permalink
Merge pull request #8 from UrbanInstitute/patch-textblock-props
Browse files Browse the repository at this point in the history
Patch textblock props
  • Loading branch information
mitchthorson authored Dec 27, 2023
2 parents 11ff84a + 671cc17 commit e118d41
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 28 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @UrbanInstitute/dataviz-components Changelog

## 0.2.0

- Update props for TextBlock component to play better with ArchieML
- Better spacing for Block component on mobile
- Add wide option for Block component

## 0.1.3

- Bugfix Add Block component to exports
Expand Down
25 changes: 8 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,21 @@

Svelte components built for Urban Institute data viz projects.

This repo is based on the SvelteKit library template.
Library documentation: https://urbaninstitute.github.io/dataviz-components

## Developing

Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:
The primrary method for developing new components locally is by running [Storybook](https://storybook.js.org/) locally. To do this, first install dependencies with

```bash
npm run dev

# or start the server and open the app in a new browser tab
npm run dev -- --open
npm install
```

Everything inside `src/lib` is part of your library, everything inside `src/routes` can be used as a showcase or preview app.
You can then run storybook with

```bash
npm run storybook
```

## Building

Expand All @@ -24,13 +25,3 @@ To build your library:
```bash
npm run package
```

To create a production version of your showcase app:

```bash
npm run build
```

You can preview the production build with `npm run preview`.

> To deploy your app, you may need to install an [adapter](https://kit.svelte.dev/docs/adapters) for your target environment.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@urbaninstitute/dataviz-components",
"version": "0.1.3",
"version": "0.2.0",
"scripts": {
"dev": "vite dev",
"build": "vite build && npm run package",
Expand Down
6 changes: 6 additions & 0 deletions src/lib/Block/Block.stories.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,10 @@
width: "full"
}}
/>
<Story
name="Wide"
args={{
width: "wide"
}}
/>

22 changes: 19 additions & 3 deletions src/lib/Block/Block.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script context="module">
/**
* @typedef {"body" | "full"} blockWidth
* @typedef {"body" | "full" | "wide"} blockWidth
*/
</script>

Expand All @@ -18,13 +18,29 @@

<style>
.layout-block {
margin: 0 auto;
width: 100%;
margin: 0 var(--spacing-4);
}
.layout-block.body {
max-width: var(--body-max-width, 760px);
}
.layout-block.full {
max-width: none;
margin: 0 auto;
width: 100%;
}
.layout-block.wide {
max-width: var(--wide-max-width, 1165px);
}
@media screen and (min-width: 792px) {
.layout-block.body {
margin: 0 auto;
}
}
@media screen and (min-width: 1197px) {
.layout-block.wide {
margin: 0 auto;
}
}
</style>
4 changes: 2 additions & 2 deletions src/lib/ProjectCredits/ProjectCredits.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
<Block>
<Heading content={heading} />
</Block>
{#each text as content}
<TextBlock {content} />
{#each text as value}
<TextBlock {value} />
{/each}
<Block>
<ul>
Expand Down
6 changes: 3 additions & 3 deletions src/lib/TextBlock/TextBlock.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import Block from "$lib/Block/Block.svelte";
/**
* The text to display in the block. Allows HTML content.
* @type {string} [textBlock]
* @type {string} [value]
*/
export let content;
export let value;
/**
* The width of the text block. Defaults to "body" (max-width: 760px)
Expand All @@ -15,7 +15,7 @@
</script>

<Block {width}>
<p class="text-block">{@html content}</p>
<p class="text-block">{@html value}</p>
</Block>

<style>
Expand Down
1 change: 1 addition & 0 deletions src/lib/style/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
--spacing-16: 4rem;
--spacing-20: 5rem;
--body-max-width: 760px;
--wide-max-width: 1165px;
--color-text-primary: var(--color-gray-shade-darkest);
--color-text-secondary: var(--color-black);
--color-text-accent: var(--color-blue);
Expand Down

0 comments on commit e118d41

Please sign in to comment.