Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Examples HLD #827

Closed
wants to merge 5 commits into from
Closed
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 89 additions & 0 deletions specs/examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# Nimble Examples
rajsite marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Member Author

@rajsite rajsite Jul 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm gonna close this PR for now. Some things I think would be useful if re-opening:

  • Split out the new cdn / bundle packages as separate work
  • Consider completely narrowing the scope of the examples to just getting started examples. At which point maybe they should just create template packages:
  • Alternative: consider separate, 1 or more?, repos that have the getting started examples. Pros: might be easier to setup (create a repo with renovate). Cons: might not be as useful for quick one off examples locally (but probably fine for stackblitz).


## Problem Statement

Nimble should have high-level well-maintained examples for our supported frameworks.

This HLD sketches out the organization and requirements of new examples and of the current examples.

## Links To Relevant Work Items and Reference Material

- [#726 Create a "Getting Started" walkthrough for Nimble Angular](https://github.com/ni/nimble/issues/726)
- [#325 Set up stackblitz or codepen template with Nimble](https://github.com/ni/nimble/issues/325)

## Implementation / Design

### Frameworks to support
- Vanilla: TypeScript + SCSS
- No explicit examples supporting vanilla JavaScript + CSS with local npm builds. Strongly encourage TS + SCSS.
- Examples will use [vite](https://vitejs.dev/)
- Supports TS + SCSS out of the box
- Web Chapter does not have an alternate recommendation yet for Vanilla apps
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Web Chapter does not have an alternate recommendation yet for Vanilla apps
- Web UI Chapter does not have an alternate recommendation yet for Vanilla apps

- Vite works on Stackblitz and local npm builds
- Parcel [does not work on Stackblitz](https://github.com/parcel-bundler/parcel/issues/7748)
- Rollup requires extra config for TS and SCSS
- Webpack aligns with the underlying technology of Angular apps but adds lots of complexity to self manage (Angular generally manages for you)
- CDN: Vanilla JS and CSS
rajsite marked this conversation as resolved.
Show resolved Hide resolved
- Uses the CDN builds of packages via unpkg.com
- Known issue: fonts are not included in the [existing example](https://github.com/ni/nimble/tree/0fe8cc54f7bd444830e3974969519593b532b083/packages/nimble-components#prototyping-in-a-static-webpage)
- We should move all the pre-built cdn bundle stuff to a [separate package](https://twitter.com/justinfagnani/status/1521953590931189760?s=20&t=zejlKVWCbEBce8zYFO7Uyg), ie:
- `@ni/nimble-bundle`
- alternative names:
- `@ni/nimble-components-cdn`
- `@ni/nimbl-components-bundle`
- `@ni/nimble-cdn-bundle`
- `@ni/nimble-cdn`
- Alternative:
- We could add a build of our CSS + font assets to the existing nimble-components bundle build which will grow the package size and pose the risk of none cdn users accidentally leveraging the contents (as described in the separate package thread linked above).
- Angular
- Blazor

### File structure
- examples/
rajsite marked this conversation as resolved.
Show resolved Hide resolved
- `<framework>`/
rajsite marked this conversation as resolved.
Show resolved Hide resolved
- README.md: Table of contents for the examples
- getting-started/
- README.md: Should include a Stackblitz link to open the example immediately in addition to other content
- package.json
- source/
- `<other examples>`: TBD
rajsite marked this conversation as resolved.
Show resolved Hide resolved

rajsite marked this conversation as resolved.
Show resolved Hide resolved
Notes:
- A subfolder per `<framework>`, i.e.: `vanilla`, `cdn`, `angular`, `blazor`
- Each `<framework>` will have a `getting-started` example.
- Getting started example will be linked from each library package README
- Getting started examples assumes brand new developers who may not have web development experience:
- guidance on IDEs
- step-by-step instructions
- links to learn more about general web topics they need to be aware of (CSS custon properties, shadow slots, etc.)
rajsite marked this conversation as resolved.
Show resolved Hide resolved
- Each example participates in the monorepo build
- Each example follows Web Chapter conventions:
- Linting configured
- Testing configured
rajsite marked this conversation as resolved.
Show resolved Hide resolved
- Detailed README
- Issue templates should be updated to include the Stackblitz urls to make it easier to report issues

### Exisiting examples
rajsite marked this conversation as resolved.
Show resolved Hide resolved
- The current [angular client example](https://github.com/ni/nimble/tree/main/angular-workspace/projects/example-client-app) and [blazor client example](https://github.com/ni/nimble/tree/main/packages/nimble-blazor/Examples)
- Will stay in current locations (angular-workspace and blazor workspace) as they are primarily developer oriented tools and not user facing examples
- Their READMEs should direct end users to the `<framework>` examples folders
- They will be renamed to `kitchen-sink` examples
- Continue to not have a Vanilla kitchen sink example
- Alternatives:
- Move the kitchen-sink examples to the examples/ folder
rajsite marked this conversation as resolved.
Show resolved Hide resolved
- Would hurt local development experience, i.e. need to run multiple angular builds / watch as a separate packge not managed by angular-workspace
- Does not seem like a high value user facing example
- Users should rely on storybook for per control usage instead

rajsite marked this conversation as resolved.
Show resolved Hide resolved
- The [counter example](https://github.com/ni/nimble/pull/796)
- Will reformat the example to be the `getting-started` example for vanilla `<framework>`, i.e. `/examples/vanilla/getting-started/<example files>`
- Will only include the final part of the example
- README will be updated to behave as a standalone example instead of a guided help / codelabs style example
rajsite marked this conversation as resolved.
Show resolved Hide resolved

## Alternative Implementations / Designs

N/A

## Open Issues

- Should we also have guided help / code labs style examples?