# Flo.w RDF UI

`@emuanalytics/flow-rdf-ui` is the Flo.w RDF web component library (`flow-ui-*` elements), with its themes and icons.
See the [Flo.w documentation](https://developer.emu-analytics.net/docsv4/) for how to use it.

## Storybook

The component stories are published as a static Storybook at <https://developer.emu-analytics.net/storybook/>.

To run Storybook locally on <http://localhost:6006>:

```sh
pnpm storybook        # in this package
pnpm storybook-ui     # or from the repo root
```

### Deploying the static Storybook

The site is hosted in the `developer.emu-analytics.net` S3 bucket (region `us-east-1`) under the `storybook/` prefix.
There is no pipeline for it: deploy from your machine.

1. **Build the libraries.** Storybook imports `flow-rdf-core` from its `dist/`, and the stories need the icons, themes
   and animations that the flow-rdf-ui build generates. From the repo root:

   ```sh
   pnpm install
   pnpm turbo run build --filter=@emuanalytics/flow-rdf-ui
   ```

2. **Build the static Storybook** into `storybook-static/` (gitignored):

   ```sh
   pnpm --filter @emuanalytics/flow-rdf-ui build-storybook
   ```

3. **Deploy it:**

   ```sh
   pnpm --filter @emuanalytics/flow-rdf-ui deploy-storybook
   ```

   `scripts/deploy-storybook.ts` syncs `storybook-static/` to `s3://developer.emu-analytics.net/storybook`. It makes
   every file `public-read` with a content type based on its extension, and it **deletes** anything under the prefix
   that isn't in the local build, so always deploy a complete build.

4. **Invalidate the CloudFront cache.** The site is served through CloudFront distribution `E1RK7JOWMYCCXB`, which
   caches files under `/storybook/` for up to 24 hours:

   ```sh
   aws cloudfront create-invalidation --distribution-id E1RK7JOWMYCCXB --paths '/storybook/*'
   ```

The deploy uses the AWS SDK's default credentials: `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY`, or an `AWS_PROFILE`
from `~/.aws`. For example, `AWS_PROFILE=<profile> pnpm --filter @emuanalytics/flow-rdf-ui deploy-storybook`. The
credentials need to list, put (including setting the object ACL) and delete objects in the bucket.

The script prints `Done` on success or `Failed - <reason>` on failure, and it exits with status 0 in both cases.
Check the last line of its output.
