Skip to content

Commit

Permalink
chore/upgrade greenwood v0.30.0 alpha.7 (#107)
Browse files Browse the repository at this point in the history
  • Loading branch information
thescientist13 authored Oct 31, 2024
1 parent 7658a0c commit 2c7f766
Show file tree
Hide file tree
Showing 19 changed files with 194 additions and 1,851 deletions.
40 changes: 14 additions & 26 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ The WTR and the full setup is covered in greater detail within [the GreenwoodJS
1. **[Mock Data Requests](https://www.greenwood.dev/guides/ecosystem/web-test-runner/#content-as-data)**
If using Greenwood's Content as Data feature, mocking `fetch` with mock data is necessary.
If using one of Greenwood's Content as Data [Client APIs](/docs/content-as-data/data-client/), mocking `fetch` with mock data is necessary.
#### Examples
Expand Down Expand Up @@ -279,38 +279,26 @@ components/
my-component.stories.js
```
#### _Content as Data_ Stories
When a component requires a `fetch` request for data, the story will need to mock this request before being able to render within the Storybook.
To mock `fetch`, create a `parameter` within the story export object named `fetchMock`. This object contains a `mocks` array with a `matcher` for the localhost network request URL. The `matcher.response` object represents the mocked data to use with the story.
Checkout [the `blog-posts-list.stories.js` story](https://github.com/ProjectEvergreen/www.greenwoodjs.dev/blob/main/src/components/blog-posts-list/blog-posts-list.stories.js) as an example.
Below is an example of a basic Storybook file:
```js
import "./my-custom-element.js";
import pages from "../../stories/mocks/graph.json";
import "./header.js";
export default {
title: "Components/My Custom Element",
parameters: {
// ...other parameters, if necessary...
fetchMock: {
mocks: [
{
matcher: {
url: "http://localhost:1985/graph.json",
response: {
body: pages,
},
},
},
],
},
},
title: "Components/Header",
};
const Template = () => "<app-header></app-header>";
export const Primary = Template.bind({});
```
#### Content as Data
When a component implements one of Greenwood's Content as Data [Client APIs](/docs/content-as-data/data-client/), the story will need to mock this request before being able to render within the Storybook.
See the [Greenwood Storybook docs](/guides/ecosystem/storybook/#content-as-data) for more information and [the _blog-posts-list.stories.js_ story](https://github.com/ProjectEvergreen/www.greenwoodjs.dev/blob/main/src/components/blog-posts-list/blog-posts-list.stories.js) for an example in this project.
## Hosting and Deployment
This project is hosted on Netlify and automatically deploys on each merge into main. Release branches will be curated over the course of a Greenwood release cycle and then merged at the time the new Greenwood release is published to NPM.
5 changes: 5 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import markdown from "@eslint/markdown";
import json from "@eslint/json";
import js from "@eslint/js";
import globals from "globals";
import noOnlyTests from "eslint-plugin-no-only-tests";

export default [
{
Expand Down Expand Up @@ -39,6 +40,10 @@ export default [
...js.configs.recommended.rules,
// turn this off for Prettier
"no-irregular-whitespace": "off",
"no-only-tests/no-only-tests": "error",
},
plugins: {
"no-only-tests": noOnlyTests,
},
},
{
Expand Down
4 changes: 2 additions & 2 deletions greenwood.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { greenwoodPluginCssModules } from "@greenwood/plugin-css-modules";
import { greenwoodPluginImportRaw } from "@greenwood/plugin-import-raw";
import { greenwoodPluginCssModules } from "./plugin-css-modules.js";

export default {
activeFrontmatter: true,
activeContent: true,

// would be nice if we could customize these plugins, like appending the autolink headings
// https://github.com/ProjectEvergreen/greenwood/issues/1247
Expand Down
Loading

0 comments on commit 2c7f766

Please sign in to comment.