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

Example apps & documentation (usage, contribution) #19

Merged
merged 38 commits into from
Aug 4, 2023
Merged
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
d4b0ec7
build(scripts): 'yalc publish' -> 'yalc push' for automatic propagati…
coopbri Aug 2, 2023
9a84590
feature(examples): add Vite + React example app
coopbri Aug 3, 2023
1e7c24b
lint(eslint): add 'examples' ignore path
coopbri Aug 3, 2023
0d477c7
lint(examples): lint Vite React example
coopbri Aug 3, 2023
9db3cdb
build(deps): upgrade dependencies
coopbri Aug 3, 2023
2911dd4
chore(types): add explicit type annotation to Button component
coopbri Aug 3, 2023
8ec8c1d
docs(usage): add library usage docs
coopbri Aug 3, 2023
015b5c6
feature(presets): add ANIREF Panda CSS preset
coopbri Aug 3, 2023
048df24
chore(examples): format tsconfig files
coopbri Aug 3, 2023
f766594
docs(readme): add usage doc links
coopbri Aug 3, 2023
d30bcff
feature(components): add Text component
coopbri Aug 3, 2023
d1c204a
build(scripts): sleep until type declaration module file emission for…
coopbri Aug 3, 2023
e87cfa0
feature(panda): emit package
coopbri Aug 3, 2023
f353d49
docs(usage): add 'emitPackage' key to Panda config template
coopbri Aug 3, 2023
3eff89c
feature(tsup): set Panda package export as external
coopbri Aug 3, 2023
c69e3ce
feature(examples): add Panda package emission to Vite demo
coopbri Aug 3, 2023
82db4c9
feature: inject package CSS, export Panda CSS and JSX constructs
coopbri Aug 3, 2023
8fa69d7
feature(examples): add Next.js example app
coopbri Aug 3, 2023
7a606d9
chore(postcss): change Panda plugin load from CJS to ESM
coopbri Aug 3, 2023
88f9c6a
docs(usage): add warning about dep installs
coopbri Aug 3, 2023
4f27410
chore: use TS base path
coopbri Aug 3, 2023
8db1a36
docs(examples): add instructions to run example apps
coopbri Aug 3, 2023
f035016
docs(usage): update details about yarn actions modifying symlinks
coopbri Aug 3, 2023
e9a79de
chore(yarn): update lock file
coopbri Aug 3, 2023
f2104a9
build(panda): remove Panda exclude array, theme color extensions
coopbri Aug 3, 2023
288e99c
feature(examples): add Panda to Next.js example
coopbri Aug 3, 2023
146c525
refactor(panda): remove package emission
coopbri Aug 3, 2023
2a3332d
chore: move comment placement
coopbri Aug 3, 2023
9325c00
docs(usage): restructure docs
coopbri Aug 3, 2023
e4eb009
docs: add changesets docs
coopbri Aug 3, 2023
945e302
docs: add contributing docs with changesets link
coopbri Aug 3, 2023
eb2c361
docs(changesets): simplify changesets docs
coopbri Aug 3, 2023
6ec01f5
ci(changesets): add changesets for Button and Text component
coopbri Aug 3, 2023
a11e616
build(deps): upgrade dependencies
coopbri Aug 4, 2023
e3c91bd
chore(tsconfig): remove emission output directory
coopbri Aug 4, 2023
4e3db30
refactor(tsup): use config factory instead of typed object
coopbri Aug 4, 2023
8a5a8d3
fix(panda): add ANIREF preset to base Panda config
coopbri Aug 4, 2023
1ab38fb
feature: export 'JsxStyleProps'
coopbri Aug 4, 2023
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
5 changes: 5 additions & 0 deletions .changeset/healthy-jeans-flash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@animareflection/ui": minor
---

Add `Text` component
5 changes: 5 additions & 0 deletions .changeset/heavy-vans-travel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@animareflection/ui": minor
---

Add `Button` component
Comment on lines +1 to +5
Copy link
Contributor Author

Choose a reason for hiding this comment

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

For future reference, no reason this changeset can't be combined with the above changeset; changesets are designed to stack. Upon a release, the changesets are "compressed" into the changelog.

1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
build
coverage
generated
examples
storybook-static

# see https://github.com/storybookjs/eslint-plugin-storybook#installation
Expand Down
3 changes: 3 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Contributing

Follow the [changesets documentation](docs/changesets.md) for guidelines on how to create changesets, which describe changes you've created.
Comment on lines +1 to +3
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This file is minimal just to have a convenient and clear entrypoint to the docs/changesets.md file, though it will be expanded in the future to include all the guidelines necessary for someone to contribute smoothly.

Also note that e.g. the changesets documentation, as well as this file, will eventually be extracted to organization-wide docs so that we have one source of truth for multiple repos using this tooling.

8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# ANIREF Design System & UI Kit

Universal design system and component library for Anima Reflection.
Universal design system and component library for Anima Reflection, powered by [Panda](https://panda-css.com/) and [Ark](https://ark-ui.com/).

## Quick Start

Follow the [prerequisities](docs/usage.md#prerequisites) to install Panda in your project, then follow the [package install instructions](docs/usage.md#from-published-package).

## Local Development

Expand All @@ -11,6 +15,8 @@ Universal design system and component library for Anima Reflection.
- [tsup](https://tsup.egoist.dev/) in watch mode
- [Storybook](https://storybook.js.org/) in development mode (default port: `6006`, e.g. http://localhost:6006)

If you'd like to develop outside of Storybook, as in a dedicated app, follow the [prerequisities](docs/usage.md#prerequisites), then follow the [local usage instructions](docs/usage.md#local).

## License

The code in this repository is licensed under MIT, &copy; Anima Reflection LLC. See <a href="LICENSE.md">LICENSE.md</a> for more information.
27 changes: 27 additions & 0 deletions docs/changesets.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Changesets 🦋

Changesets ([Wikipedia](https://en.wikipedia.org/wiki/changeset)) represent an _intent_ to evolve a project in the form of a collection of changes. This project uses a tool with the same name, [Changesets](https://github.com/changesets/changesets), to manage them and handle the versioning, changelog generation, and release lifecycle.

## Creation

1. To create a changeset, run `yarn changeset` in the project directory.

2. You will be prompted to select a bump type, based on the [SemVer](https://semver.org/) spec.

3. Write a message describing the change, using present tense and starting with a verb. For example, if you are adding a new component called `Card`, you might write:

```
Add `Card` component
```

If you're fixing a bug for the Card component, you might write:

```
Fix `Card` resizing after initial page load
```

After the changeset is created, it will be added to the `.changeset` folder, where it can be safely modified and committed. There is no limit to the number of changesets you can create, even in one PR.

## Learn More

View the [official Changesets documentation](https://github.com/changesets/changesets/tree/main#documentation) to learn more about the tool and how to use it.
70 changes: 70 additions & 0 deletions docs/usage.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# ANIREF UI Library Usage

Follow these steps to use the ANIREF UI library in your project.

## Prerequisites

1. Install [Panda 🐼](https://panda-css.com/): `yarn add -D @pandacss/dev`

2. Create a Panda config file similar to this (Panda looks for `panda.config.ts` by default):

```ts
// panda.config.ts
import { anirefPreset } from "@animareflection/ui";
import { defineConfig } from "@pandacss/dev";

const pandaConfig = defineConfig({
preflight: true,
presets: ["@pandacss/dev/presets", anirefPreset],
include: ["src/**/*.{ts,tsx}"],
outdir: "src/generated/panda",
});

export default pandaConfig;
```

3. Create a CSS file and import it into your project. You can name the CSS file anything you want, just make sure you import it early in your project. For example:

```css
/* main.css */
@layer reset, base, tokens, recipes, utilities;
@import url("@animareflection/ui/index.css");
```

```tsx
// App.tsx
import "main.css";

const App = () => <></>;
```

Now you are ready to install the UI library. You can either install it [from the published package](#from-published-package) or from a [local clone](#local) on your local filesystem. The latter is useful if you are developing the library.

## Remote

Install from remote repository: `yarn add @animareflection/ui`

## Local

This workflow is ideal for local development.

1. Install [yalc](https://github.com/wclr/yalc)
2. **Within the root UI library directory**, build the UI library: `yarn build` (or `yarn dev` for continuous builds)
3. **Within the project directory:**

1. Install dependencies: `yarn`
2. Link the UI library: `yalc link @animareflection/ui`. Linking will not modify `package.json`, it will just symlink the package into your `node_modules`. Note that the package must be published to the `yalc` store first (this happens automatically after a successful build of the UI library)

> 💡 **Note:** if you receive a `Cannot find module '@animareflection/ui' [...]` error and `yarn && yalc link @animareflection/ui` does not resolve the issue, try removing the `yalc.lock` file and then relink:
>
> ```sh
> rm yalc.lock && yalc link @animareflection/ui
> ```

> 💡 **Note:** every time you install or modify dependencies (e.g. run `yarn` or `yarn add [...]`), the package symlink will be cleared, and will need to be relinked:
>
> ```sh
> yarn && yalc link @animareflection/ui
> ```

> 💡 **Note:** if the UI library build fails, this will cause trickling errors. Make sure the UI library builds successfully if you are still having issues.
21 changes: 21 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# ANIREF UI Example Apps

## Overview

- `next`: Next.js example
- `vite`: React + Vite example

## Run

### From this repository

To run any of these examples from within the repository, follow the [local usage instructions](../docs/usage.md#local).

### Externally (by copying the examples out of this repository)

1. Simply install the included dependencies and add the UI library package:

```sh
yarn
yarn add @animareflection/ui # (or link with `yalc` as above)
```
4 changes: 4 additions & 0 deletions examples/next/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"root": true,
"extends": "next/core-web-vitals"
}
5 changes: 5 additions & 0 deletions examples/next/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.yarn
.yalc
yalc.lock
.next
next-env.d.ts
1 change: 1 addition & 0 deletions examples/next/.yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodeLinker: pnpm
6 changes: 6 additions & 0 deletions examples/next/next.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
};

module.exports = nextConfig;
25 changes: 25 additions & 0 deletions examples/next/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "ui-next-example",
"private": true,
"license": "MIT",
"scripts": {
"dev": "rm -rf .next && next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"devDependencies": {
"@pandacss/dev": "^0.9.0",
"@types/node": "^20.4.6",
"@types/react": "^18.2.18",
"@types/react-dom": "^18.2.7",
"eslint": "^8.46.0",
"eslint-config-next": "^13.4.12",
"typescript": "^5.1.6"
},
"dependencies": {
"next": "^13.4.12",
"react": "^18.2.0",
"react-dom": "^18.2.0"
}
}
16 changes: 16 additions & 0 deletions examples/next/panda.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { anirefPreset } from "@animareflection/ui";
import { defineConfig } from "@pandacss/dev";

/**
* Panda configuration.
*
* @see https://panda-css.com/docs/references/config
*/
const pandaConfig = defineConfig({
preflight: true,
presets: ["@pandacss/dev/presets", anirefPreset],
include: ["src/**/*.{ts,tsx}"],
outdir: "src/generated/panda",
});

export default pandaConfig;
18 changes: 18 additions & 0 deletions examples/next/src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { ReactNode } from "react";

interface Props {
children: ReactNode;
}

/**
* Root application layout.
*/
const RootLayout = ({ children }: Props) => (
<html lang="en" style={{ height: "100%" }}>
<head />

<body>{children}</body>
</html>
);

export default RootLayout;
58 changes: 58 additions & 0 deletions examples/next/src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
"use client";

import { Circle, Flex, Grid, Square, Text } from "@animareflection/ui";

import "main.css";

const HomePage = () => (
<Flex
gradientFrom="white"
gradientTo="brand.primary.100"
bgGradient="to-b"
direction="column"
h="100%"
align="center"
gap={4}
pt={12}
>
<Text color="brand.primary.500" fontSize="3xl" fontWeight="bold">
Anima Reflection UI library demo
</Text>

<a href="https://nextjs.org/" target="_blank" rel="noopener noreferrer">
<img
src="https://upload.wikimedia.org/wikipedia/commons/8/8e/Nextjs-logo.svg"
width="200px"
/>
</a>

<Grid
gridTemplateColumns="1fr 1fr"
px={4}
w="100%"
alignItems="center"
justifyItems="center"
>
<Square
size={40}
color="white"
bgColor="brand.primary.500"
fontWeight="bold"
fontSize="2xl"
>
Square
</Square>

<Circle
size={40}
bgColor="brand.secondary.300"
fontWeight="bold"
fontSize="2xl"
>
Circle
</Circle>
</Grid>
</Flex>
);

export default HomePage;
2 changes: 2 additions & 0 deletions examples/next/src/main.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@layer reset, base, tokens, recipes, utilities;
@import url("@animareflection/ui/index.css");
37 changes: 37 additions & 0 deletions examples/next/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"compilerOptions": {
"target": "ESNext",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"baseUrl": "src",
"strict": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"incremental": true,
"plugins": [
{
"name": "next"
}
]
},
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx",
".next/types/**/*.ts"
],
"exclude": [
"node_modules"
]
}
Loading