diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 35a75fd..805dd79 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -17,3 +17,4 @@ Tell us what this PR does or link to any related issues that describe the goal h - [ ] Added any changes in this PR to the `CHANGELOG.md` `Next` section - [ ] If this pull request includes a new component or feature, has it been exported from one of the library's entry points? - [ ] Does the component dispatch relevant interaction events? (ie: on:click, on:change, etc.) +- [ ] Does the component directory include description and usage information in `.stories.svelte`? diff --git a/CHANGELOG.md b/CHANGELOG.md index aefa16e..6854c3e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ - Patch: Update BasicDropdown with better accessibility (icon hidden from screen readers) - Feature: GitHub source links for components via [@etchteam/storybook-addon-github-link](https://storybook.js.org/addons/@etchteam/storybook-addon-github-link) in storybook docs +- Patch: Update method of declaring Storybook component descriptions and add import instructions to components +- Patch: Remove description field from top level `meta` object in component `.stories.svelte` files (do not render) ## v0.10.2 diff --git a/src/docs/stories/BasicPage.stories.svelte b/src/docs/stories/BasicPage.stories.svelte index e31b8e5..9bca511 100644 --- a/src/docs/stories/BasicPage.stories.svelte +++ b/src/docs/stories/BasicPage.stories.svelte @@ -1,14 +1,6 @@ diff --git a/src/docs/stories/CustomSVGMap.stories.svelte b/src/docs/stories/CustomSVGMap.stories.svelte index 200a262..fcc283e 100644 --- a/src/docs/stories/CustomSVGMap.stories.svelte +++ b/src/docs/stories/CustomSVGMap.stories.svelte @@ -1,25 +1,13 @@ diff --git a/src/docs/stories/DatawrapperSwitching.stories.svelte b/src/docs/stories/DatawrapperSwitching.stories.svelte index 22d6ccd..9f58366 100644 --- a/src/docs/stories/DatawrapperSwitching.stories.svelte +++ b/src/docs/stories/DatawrapperSwitching.stories.svelte @@ -1,7 +1,6 @@ diff --git a/src/docs/stories/DynamicInfoStores.stories.svelte b/src/docs/stories/DynamicInfoStores.stories.svelte index f80b797..ed1c551 100644 --- a/src/docs/stories/DynamicInfoStores.stories.svelte +++ b/src/docs/stories/DynamicInfoStores.stories.svelte @@ -1,7 +1,6 @@ diff --git a/src/lib/Analytics/Analytics.docs.mdx b/src/lib/Analytics/Analytics.docs.mdx index ff4f8fa..5319b3c 100644 --- a/src/lib/Analytics/Analytics.docs.mdx +++ b/src/lib/Analytics/Analytics.docs.mdx @@ -1,6 +1,13 @@ import * as Stories from "./Analytics.stories.svelte"; -import { Meta, Story, Stories as StoriesDocBlock, Canvas, Controls, Primary, Source } from '@storybook/blocks'; - +import { + Meta, + Story, + Stories as StoriesDocBlock, + Canvas, + Controls, + Primary, + Source +} from "@storybook/blocks"; @@ -8,6 +15,10 @@ import { Meta, Story, Stories as StoriesDocBlock, Canvas, Controls, Primary, Sou A component that adds Urban Institute's Google Analytics to your page. This will enable tracking of page views and custom events in your project. +```js +import { Analytics } from "@urbaninstitute/dataviz-components"; +``` + ## Properties The `Analytics` component has the following properties. @@ -18,35 +29,44 @@ The `Analytics` component has the following properties. By default, this will add Google analytics' `gtag` to your page and fire a page view. If you are using Urban Institute's dataviz project template, you'll likely want to include this in your `+layout.svelte` or on your `+page.svelte` routes. - import { Analytics } from "@urbaninstitute/dataviz-components"; -`} language="html"/> +`} + language="html" +/> If you'd like to avoid firing a pageview because you're creating an en embed or for any other reason, you can do so by setting `sendPageview` to `false`. - import { Analytics } from "@urbaninstitute/dataviz-components"; -`} language="html"/> +`} + language="html" +/> Anytime you have an event handler, use this one-line function call to send relevant data through to Google Analytics: +/\*\* + +- sends event data to GTM and GA. call in event handlers for each event type you wish to track. +- A function that logs a click event to Google Analytics. +- @param {HTMLElement} target The DOM element that triggered the event. +- @param {string} eventName A string in the format "event_name--event_specifics" where "event_name is the type of event, such as "map_click" or "dropdown_select" and "event_specifics" refers to the selected option, region, or specific function. + \*/ + logClickToGA(target, eventName); + `} language="js"/> An example of logClickToGA in action: @@ -54,11 +74,9 @@ An example of logClickToGA in action: import { logClickToGA } from "@urbaninstitute/dataviz-components"; myElement.addEventListener("click", (e) => { - logClickToGA( - e.target, - "map_click--" + e.detail.hoverData.hoverCounty + ", " + e.detail.hoverData.hoverStateName - ); +logClickToGA( +e.target, +"map_click--" + e.detail.hoverData.hoverCounty + ", " + e.detail.hoverData.hoverStateName +); }); `} language="js"/> - - diff --git a/src/lib/Analytics/Analytics.stories.svelte b/src/lib/Analytics/Analytics.stories.svelte index 6c635bb..8ea71b1 100644 --- a/src/lib/Analytics/Analytics.stories.svelte +++ b/src/lib/Analytics/Analytics.stories.svelte @@ -3,14 +3,8 @@ export const meta = { title: "Components/Analytics", - description: "A component that provides Google Analytics functionality to your page.", component: Analytics, parameters: { - docs: { - description: { - component: "A component that provides Google Analytics functionality to your page." - } - }, githubLink: { url: "/Analytics/Analytics.svelte" } diff --git a/src/lib/BasicDropdown/BasicDropdown.docs.md b/src/lib/BasicDropdown/BasicDropdown.docs.md new file mode 100644 index 0000000..08eb52b --- /dev/null +++ b/src/lib/BasicDropdown/BasicDropdown.docs.md @@ -0,0 +1,5 @@ +Basic HTML dropdown adhering to Urban styles. + +```js +import { BasicDropdown } from "@urbaninstitute/dataviz-components"; +``` diff --git a/src/lib/BasicDropdown/BasicDropdown.stories.svelte b/src/lib/BasicDropdown/BasicDropdown.stories.svelte index aaddf9c..8f6b820 100644 --- a/src/lib/BasicDropdown/BasicDropdown.stories.svelte +++ b/src/lib/BasicDropdown/BasicDropdown.stories.svelte @@ -2,10 +2,10 @@ import BasicDropdown from "./BasicDropdown.svelte"; import IconDownload from "$lib/Button/IconDownload.svelte"; import urbanColors from "$lib/utils/urbanColors.js"; + import docs from "./BasicDropdown.docs.md?raw"; export const meta = { title: "Components/BasicDropdown", - description: "A basic dropdown component that uses a