Skip to content

Commit 82c02e0

Browse files
committed
feat: introduce sheet
1 parent 2815338 commit 82c02e0

14 files changed

+2804
-623
lines changed

.github/.CONTRIBUTING.md

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Contributing Guide
2+
3+
Thank you for your interest in contributing to our project! Before you submit a pull request, we kindly ask you to review this guide thoroughly.
4+
5+
## Development
6+
7+
First, [fork](https://docs.github.com/en/get-started/quickstart/fork-a-repo) and clone the repository onto your local machine. Once you have your local copy of the repository, you can commence with development. This typically involves installing the required dependencies and executing the tests.
8+
9+
### Install Dependencies
10+
11+
After cloning the repository, navigate to its root directory and run the following command to install the necessary dependencies:
12+
13+
```
14+
npm install
15+
```
16+
17+
Once you have made your changes and verified they work correctly, you can submit a [pull request from your forked repository](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request-from-a-fork).
18+
19+
## Pull Requests
20+
21+
Before proposing changes, please open an [issue](https://github.com/@sheet-ui/sheet/issues/new) or [discussion](https://github.com/@sheet-ui/sheet/discussions/new/choose) for collaborative decision-making on solutions prior to submitting a pull request. This enhances the effectiveness of your contributions and promotes collective input.
22+
23+
### Workflow
24+
25+
1. **Open an [issue](https://github.com/@sheet-ui/sheet/issues/new)**: Start by opening an issue detailing the problem you want to solve or the feature you want to add.
26+
1. **Fork and branch:** Fork the repository and create a new branch on your fork to work on the changes.
27+
1. **Add commits:** Add new commits to your branch. Remember:
28+
1. Commits should be [concise, descriptive, and well formatted](https://cbea.ms/git-commit/#seven-rules).
29+
1. Commits should follow the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0) specification and use the [standard headings](https://github.com/googleapis/release-please/blob/cb0f936e598c5bfb8d3e0a9c0eeb57ae59a35140/src/changelog-notes.ts#L43-L54).
30+
1. This repository maintains a linear git history, so merge commits are not allowed.
31+
1. **Open a pull request:** Open a [new pull request](https://github.com/@sheet-ui/sheet/compare) on GitHub, and [link](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue) it to the issue you created in the first step.
32+
33+
### Dependabot
34+
35+
This repository employs [Dependabot 🤖](https://docs.github.com/en/code-security/dependabot) to [secure](https://docs.github.com/en/code-security/dependabot/dependabot-security-updates/configuring-dependabot-security-updates) and [update](https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuring-dependabot-version-updates#about-version-updates-for-dependencies) project dependencies by automatically initiating pull requests for package upgrades. The duty of project maintainers is to review, test, approve, and merge these Dependabot-generated pull requests.
36+
37+
## Release
38+
39+
Project maintainers are entrusted with the task of publishing new releases. Releases are automated with Google's [release-please](https://github.com/googleapis/release-please) GitHub action. Simply put, to publish a release, you simply need to merge the release pull request (PR) 🚀.
40+
41+
The release-please GitHub action parses [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0) to help automate the release process. It automatically generates a release PR, which is continuously updated as new commits are merged into the main branch. Once maintainers decide that it's time to publish a new release, they can merge the release PR.
42+
43+
Upon merging the release PR, the GitHub action initiates a series of tasks:
44+
45+
1. Updates the `CHANGELOG.md` and `package.json` files.
46+
1. Tags the commit associated with the release with the [version](https://semver.org) number.
47+
1. Creates a new GitHub release based on this tag.
48+
1. Publishes a new version of [the package](https://www.npmjs.com/package/@sheet-ui/sheet) to npm.
49+
50+
## Versioning
51+
52+
This project follows [Semantic Versioning 2.0](https://semver.org/) and the release tooling automatically parses the semantic version based on the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0).

.github/ISSUE_TEMPLATE/bug_report.yml

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Bug Report
2+
description: File an issue
3+
title: "[bug] <replace this with a title>"
4+
body:
5+
- type: markdown
6+
attributes:
7+
value: |
8+
Thanks for taking the time to fill out this bug report. Please provide thorough context of the issue.
9+
10+
- type: input
11+
attributes:
12+
label: Version
13+
description: What version of @sheet-ui/sheet are you using?
14+
placeholder: 0.0.x
15+
validations:
16+
required: true
17+
18+
- type: textarea
19+
attributes:
20+
label: Unexpected behavior
21+
description: A thorough description of the unexpected behavior. You can also attach images, videos, code snippets below.
22+
validations:
23+
required: true
24+
25+
- type: textarea
26+
attributes:
27+
label: Expected behavior
28+
description: A thorough description of the expected behavior.
29+
validations:
30+
required: true
31+
32+
- type: textarea
33+
attributes:
34+
label: Steps to reproduce
35+
description: Steps to reproduce the unexpected behavior.
36+
validations:
37+
required: false
38+
39+
- type: input
40+
attributes:
41+
label: Minimal reproducible demo of issue
42+
description: |
43+
A link to a demo makes investigating the issue easier. Demos can be hosted on CodeSandbox or GitHub.
44+
placeholder: https://codesandbox.io
45+
validations:
46+
required: false
47+
48+
- type: textarea
49+
attributes:
50+
label: Anything else?
51+
description: |
52+
Anything that will provide more context about the issue. You can also attach images, videos, code snippets below.
53+
54+
validations:
55+
required: false

.github/workflows/release-please.yaml

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
on:
2+
push:
3+
branches:
4+
- main
5+
name: release-please
6+
jobs:
7+
release-please:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: google-github-actions/release-please-action@v3
11+
id: release
12+
with:
13+
release-type: node
14+
package-name: test-release-please
15+
# The logic below handles the npm publication:
16+
- uses: actions/checkout@v3
17+
# these if statements ensure that a publication only occurs when
18+
# a new release is created:
19+
if: ${{ steps.release.outputs.release_created }}
20+
- uses: actions/setup-node@v3
21+
with:
22+
node-version: 20
23+
registry-url: "https://registry.npmjs.org"
24+
if: ${{ steps.release.outputs.release_created }}
25+
- run: npm ci
26+
if: ${{ steps.release.outputs.release_created }}
27+
- run: npm run build
28+
if: ${{ steps.release.outputs.release_created }}
29+
- run: npm publish --access public
30+
env:
31+
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
32+
if: ${{ steps.release.outputs.release_created }}

.gitignore

+5-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1-
node_modules
1+
# dependencies
2+
node_modules
3+
4+
# artifacts
5+
dist

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) [2024] ⟠ henryzhu.eth ⟠
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Sheet
2+
3+
A mobile web sheet that replicates the Apple-style [sheet experience](https://developer.apple.com/design/human-interface-guidelines/sheets), designed to be accessible to all users.
4+
5+
<div style="display: flex; justify-content: center;">
6+
<img src="https://docs-assets.developer.apple.com/published/1f52d50425bf3c15d9fc7b46e2c99043/[email protected]" width="35%" style="margin-right: 10px;" />
7+
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
8+
<img src="https://docs-assets.developer.apple.com/published/51b039c96928a882bd7c7c743976b548/[email protected]" width="35%" />
9+
</div>
10+
11+
## Installation
12+
13+
To use Sheet in your project follow these instructions.
14+
15+
### Step 1: Install peer dependency
16+
17+
First, make sure you have the required peer dependency [framer-motion](https://github.com/framer/motion) installed. If you haven't installed it yet, you can do so with the following command:
18+
19+
```
20+
npm install framer-motion
21+
```
22+
23+
### Step 2: Install Sheet
24+
25+
After installing the peer dependency, proceed to install the [@sheet-ui/sheet](https://www.npmjs.com/package/@sheet-ui/sheet) package:
26+
27+
```
28+
npm install @sheet-ui/sheet
29+
```
30+
31+
### Step 3: Use the component
32+
33+
Now, you can integrate the component into your React codebase. See the example below for usage.
34+
35+
## Usage
36+
37+
The component API provides consumers with a high level of rendering control through a simple interface.
38+
39+
```tsx
40+
function Example() {
41+
const [isOpen, setOpen] = useState(false);
42+
const toggle = () => setOpen(!isOpen);
43+
44+
return (
45+
<Sheet size="sm" isOpen={isOpen} onDismiss={toggle}>
46+
<button onClick={toggle}>Open</button>
47+
<SheetContent>
48+
<SheetHeader>Title</SheetHeader>
49+
<div>Some content goes here</div>
50+
</SheetContent>
51+
</Sheet>
52+
);
53+
}
54+
```
55+
56+
## Development
57+
58+
To develop `@sheet-ui/sheet`, link the local library to a local test application created with tools like Create React App (CRA), Next.js, or Remix. You can achieve this using `npm link` to connect your library with the test app.
59+
60+
To avoid issues caused by multiple React instances (such as hooks failing due to different React copies), ensure that both the library and the consumer app share the same React dependency."
61+
62+
In the root directory of your library, run the following command to link React from your consumer app:
63+
64+
```sh
65+
npm link ../my-library-consumer/node_modules/react
66+
```
67+
68+
Then in the root directory of the consumer app:
69+
70+
```sh
71+
npm link @sheet-ui/sheet
72+
```
73+
74+
## Disclaimer
75+
76+
Avoid using sheets on desktop platforms; instead, opt for regular modals in desktop applications. While drawing inspiration from Apple's operating system can be beneficial, it's important to remember that the web is a unique platform. Web design should respect its distinct nature, rather than attempting to mimic native iOS or other operating systems entirely. Ensure you are following semantic and accessible web standards.

dist/index.cjs.js

-41
This file was deleted.

dist/index.d.ts

-9
This file was deleted.

dist/index.esm.js

-17
This file was deleted.

esbuild.config.mjs

+20-18
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,28 @@ import { build } from "esbuild";
22

33
const isProduction = process.env.NODE_ENV === "production";
44

5-
// Build for CommonJS
65
build({
7-
entryPoints: ["src/index.tsx"], // or 'src/index.jsx' if not using TypeScript
8-
bundle: true,
9-
outfile: "dist/index.cjs.js",
10-
platform: "node",
11-
target: ["es6"], // Target ECMAScript 6
12-
format: "cjs", // CommonJS format
13-
external: ["react", "react-dom"], // Don't bundle React and ReactDOM
14-
sourcemap: !isProduction,
6+
entryPoints: ["src/index.tsx"],
7+
bundle: true,
8+
outfile: "dist/index.cjs.js",
9+
platform: "node",
10+
target: ["es6"],
11+
format: "cjs",
12+
external: ["react", "react-dom", "framer-motion"],
13+
sourcemap: !isProduction,
14+
minify: isProduction,
15+
treeShaking: isProduction,
1516
}).catch(() => process.exit(1));
1617

17-
// Build for ESModule
1818
build({
19-
entryPoints: ["src/index.tsx"],
20-
bundle: true,
21-
outfile: "dist/index.esm.js",
22-
platform: "neutral",
23-
target: ["es6"],
24-
format: "esm", // ESModule format
25-
external: ["react", "react-dom"],
26-
sourcemap: !isProduction,
19+
entryPoints: ["src/index.tsx"],
20+
bundle: true,
21+
outfile: "dist/index.esm.js",
22+
platform: "neutral",
23+
target: ["es6"],
24+
format: "esm",
25+
external: ["react", "react-dom", "framer-motion"],
26+
sourcemap: !isProduction,
27+
minify: isProduction,
28+
treeShaking: isProduction,
2729
}).catch(() => process.exit(1));

0 commit comments

Comments
 (0)