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

Migrate to Vite #213

Open
wants to merge 48 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 46 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
77c66ee
Initial commit
dfosco Jan 20, 2025
8e132fc
Build commit
dfosco Jan 20, 2025
685fd6d
Build commit
dfosco Jan 20, 2025
24ab40f
Improve page logic and components
dfosco Jan 20, 2025
b12b90e
Build commit
dfosco Jan 20, 2025
c0c257e
Build commit
dfosco Jan 20, 2025
447cdfb
Layout adjustments
dfosco Jan 20, 2025
21c73bc
Build commit
dfosco Jan 20, 2025
a66a960
Update deploy script
dfosco Jan 20, 2025
8464bf8
Update configs
dfosco Jan 21, 2025
f32ef3a
Config updates
dfosco Jan 21, 2025
5b7f1d0
Update filetypes to jsx
dfosco Jan 21, 2025
d57d149
Add customizable JSON for GlobalNav
dfosco Jan 21, 2025
59cd926
Finish pagination refactor
dfosco Jan 21, 2025
a7b860f
Build commit
dfosco Jan 21, 2025
1c24efc
Fix color modes
dfosco Jan 21, 2025
4c7e96e
Build commit
dfosco Jan 21, 2025
56b7176
Update package.json
dfosco Jan 21, 2025
1ffad27
Mid-worshop updates
dfosco Jan 21, 2025
ba2782e
Small fix
dfosco Jan 21, 2025
16daac5
Make code page as the index
dfosco Jan 22, 2025
905eb31
Create deploy.yml
dfosco Jan 22, 2025
29607d4
Add vite migration setup
dfosco Jan 22, 2025
0ed81eb
Merge branch 'migrate-vite'
dfosco Jan 22, 2025
dacd15b
Config adjustments
dfosco Jan 22, 2025
b6277ae
Update dependency
dfosco Jan 22, 2025
9d0e4b4
Update workflow
dfosco Jan 22, 2025
5cb6537
Update package.json
dfosco Jan 22, 2025
7310e18
Update workflow
dfosco Jan 22, 2025
f5c2ae9
Update workflow [2]
dfosco Jan 22, 2025
d9d5d7e
Rename package
dfosco Jan 22, 2025
a1364d9
Comment out HTML redirects
dfosco Jan 22, 2025
04639d9
Revert "Comment out HTML redirects"
dfosco Jan 22, 2025
7751a7a
Update localhost port
dfosco Jan 22, 2025
095bfbf
Update README
dfosco Jan 22, 2025
9610a6b
Update README
dfosco Jan 22, 2025
df93ad0
Update README
dfosco Jan 22, 2025
fd066e2
Update README
dfosco Jan 22, 2025
c53bf9f
Update favicon
dfosco Jan 22, 2025
b3df7c5
Update README.md
dfosco Jan 22, 2025
52a388d
Update README.md
dfosco Jan 22, 2025
a08c74e
Update README.md
dfosco Jan 22, 2025
ec209b6
Update README.md
dfosco Jan 22, 2025
06f41e7
Re-add Playground as index
dfosco Mar 11, 2025
66c58f0
Update README and Playground index
dfosco Mar 11, 2025
2c3216c
Merge changes from github/primer-react-prototype
dfosco Mar 12, 2025
5bf5d64
Fix merge leftovers
dfosco Mar 25, 2025
d362259
Merge branch 'main' into migrate-to-vite
dfosco Mar 25, 2025
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
51 changes: 51 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Deploy

on:
push:
branches:
- main

jobs:
build:
name: Build
runs-on: ubuntu-latest

steps:
- name: Checkout repo
uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v3

- name: Install dependencies
run: npm ci --legacy-peer-deps

- name: Build project
run: npm run build

- name: Upload static files as artifact
id: deployment
uses: actions/upload-pages-artifact@v3 # or specific "vX.X.X" version tag for this action
with:
path: dist/

deploy:
# Add a dependency to the build job
needs: build

# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
permissions:
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source

# Deploy to the github-pages environment
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

# Specify runner + deployment step
runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4 # or specific "vX.X.X" version tag for this action
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

<<<<<<< HEAD
=======
#build
dist

>>>>>>> 66c58f06f60ba27ba01e7ac0e8ccb83d2d81b319
# dependencies
/node_modules
/.pnp
.pnp.js

<<<<<<< HEAD
# testing
/coverage

# production
/build

=======
>>>>>>> 66c58f06f60ba27ba01e7ac0e8ccb83d2d81b319
# misc
.DS_Store
.env.local
Expand Down
Binary file added .readme/image-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .readme/image-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .readme/image-codespace.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .readme/image-ports-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .readme/image-ports-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .readme/image-ports-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .readme/image-ports.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .readme/image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
// Hide git ignored files
"explorer.excludeGitIgnore": false
}
151 changes: 151 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<<<<<<< HEAD
# Primer React Template 🐱⚛️

The quickest way to test out or prototype something in [Primer React](https://primer.style/react/) without having to set up a new project.
Expand Down Expand Up @@ -25,6 +26,137 @@ https://user-images.githubusercontent.com/980622/135662854-946e5d2d-b6d1-4cbf-a7
5. Go to `src/Playground.js` to start prototyping.

(For GitHub staff only) Check out this talk (9 minutes 30 seconds) from @heyamie for more tips on [prototyping with Primer React](https://github.rewatch.com/video/sniwdhyn3qqcvjsq-prototyping-with-primer-react-lightning-talk).
=======
# Primer React Prototype ⚛️⚡

The easiest way to build a prototype from scratch with [Primer React](https://primer.style/react/) and deploy with GitHub Pages.

Perfect for quick prototyping with code, and setup to be visible only for signed-in Hubbers. Works (mostly) out of the box!

*Built using [vite.dev](https://vite.dev/guide/), see their docs if you want to customize any configuration (you shouldn't have to).*

## Get Started (Quick setup - Codespaces)

<details>
<summary>
See instructions
</summary>

### Create a codespace

1. Create a codespace for your prototype by clicking **Use this template** > **Open in a codespace**

2. In the codespaces terminal, run:

```bash
npm install
```
```bash
npm run dev
```

Once `npm run dev` is running, go to the **PORTS tab** in the terminal and open the URL for your prototype:

![Screenshot showing the ports tab and Port URL](.readme/image-ports-1.png)

If the **PORTS tab** is not visible for you, right-click next to the other tabs and enable it in the dropdown menu:

![Screenshot showing how to enable the ports tab](.readme/image-ports.png)

### Sharing your prototype

This is a temporary URL that's only live while `npm run dev` is running in your Codespace.

To make the URL accessible for others, change its visibility:

1. Go to **PORTS** tab
2. On the Visibility column, right click on **🔒 Private**
3. Choose **Port visibility** on the dropdown
4. Change it to **Private to Organization**

![Screenshot matching the description above](.readme/image-ports-3.png)

To share a permanent URL, see [Get Started (Local development)](#get-started-local-development) below.

### Saving your codespace into a repository

If you try to `git push` from your codespace terminal, you will notice there is no repository associated with it.

To save your work, create a new empty repository owned by **@github** and set your codespace to it by running:

```bash
git remote add origin [email protected]:github/YOUR_REPO_NAME.git
git branch -M main
git push -u origin main
```

Once you have a repository saved, you should finish the configuration under [Deploying your prototype](#deploying-your-prototype).

You don't need to develop locally, however. You can always keep building in the browser, just choose the Coodespaces tab under the Code button:

![Code button and Codespaces tab opened in the dialog below](.readme/image-codespace.png)

</details>

## Get Started (Local development)

<details>
<summary>See instructions</summary>

### Start your repository
1. Create a repository for your prototype by clicking **Use this template** > **Create a new repository**

2. Set the repository Owner as **github** so that the deployment is only enabled for Hubbers. Choose whatever name you want.

3. Clone your new repo locally

### Developing

You need to have nodejs installed on your machine. If you don't, [head here](https://nodejs.org/en/download) and choose macOS installer.

Once you have the repository cloned on your machine, open the folder on VSCode or the terminal and run:

```bash
npm install
```

```bash
npm run dev
```

You will see the site running on http://localhost:1234

## Deploying your prototype

You need to change a few settings on GitHub.com for your prototype to be deployed & visible. This cannot be automated at the moment unfortunately!

1. Go to your repository, then **Settings > Pages**:
- Set GitHub Pages visibility to **Private**
- Set Build and deployment source to **GitHub Actions**

![Screenshot showing the UI with the descriptions above](.readme/image.png)

2. Go to your repository, then **Settings > Collaborators and teams**:
- Click "Add teams"
- Add **github/employees** with at least "Read" permission

![Manage access UI showing "Add teams" and the @github/employees team already added](.readme/image-2.png)

3. Push your first commit after setting this up, and you will see your prototype available on an auto-generated URL under **Settings > Pages**. Share this URL with any Hubber and they will see it too!

![Interface written: GitHub Pages - Your site is live at https://refactored-guacamole-6kolnpq.pages.github.io/](.readme/image-1.png)

<details>
<summary>Extra options</summary>

- Add your Pages URL to the repository description:
- On your repository homepage, click the gear (⚙️) icon next to **About** to edit the description
- On the modal check **Use your GitHub Pages website**
- Save changes, and your URL will be visible
</details>

</details>
>>>>>>> 66c58f06f60ba27ba01e7ac0e8ccb83d2d81b319

## 10 reasons why this is great

Expand All @@ -43,3 +175,22 @@ https://user-images.githubusercontent.com/980622/135662854-946e5d2d-b6d1-4cbf-a7

- [🧠 Primer React Documentation](https://primer.style/react/)
- [🌈 Primer Primitives (Colors)](https://primer.style/primitives/colors)
<<<<<<< HEAD
=======

## Tips and Tricks

- Use [Primer React](https://primer.style/components) components to build your layouts, or check [Primer Templates](https://ui.githubapp.com/storybook/?path=/docs/templates-readme--docs&globals=viewport:narrow) (staff only) to get a starting point.
- To create new pages, duplicate any file in the `/pages` folder and rename it to `whatever.jsx`. Now head to `localhost:1234/whatever` and you will see your new page loaded
- Also check out [this talk](https://www.youtube.com/watch?v=XroAmpITjsI) from [@heyamie](https://github.com/heyamie) for more tips on prototyping. Some parts are only relevant for NextJS projects, but a lot still applies!

## Dealing with errors

#### `npm: command not found`

If you try to run `npm install` and get an error similar to the one described above, that means you don't have Node/npm installed on your machine. In that case, [head here to download it](https://nodejs.org/en/download). Choose macOS installer for the simplest option.

#### Any other error

Please open an issue or send a message on `#primer` in Slack (staff only). This repository is built to be a simple prototyping experience for designers and other non-developers. If it doesn't work out of the box, **the template is wrong, not you** -- please reach and the Primer team will help!
>>>>>>> 66c58f06f60ba27ba01e7ac0e8ccb83d2d81b319
38 changes: 38 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import js from '@eslint/js'
import globals from 'globals'
import react from 'eslint-plugin-react'
import reactHooks from 'eslint-plugin-react-hooks'
import reactRefresh from 'eslint-plugin-react-refresh'

export default [
{ ignores: ['dist'] },
{
files: ['**/*.{js,jsx}'],
languageOptions: {
ecmaVersion: 2020,
globals: globals.browser,
parserOptions: {
ecmaVersion: 'latest',
ecmaFeatures: { jsx: true },
sourceType: 'module',
},
},
settings: { react: { version: '18.3' } },
plugins: {
react,
'react-hooks': reactHooks,
'react-refresh': reactRefresh,
},
rules: {
...js.configs.recommended.rules,
...react.configs.recommended.rules,
...react.configs['jsx-runtime'].rules,
...reactHooks.configs.recommended.rules,
'react/jsx-no-target-blank': 'off',
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
},
},
]
38 changes: 38 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Primer React Prototype</title>

<!-- Start Single Page Apps for GitHub Pages -->
<script type="text/javascript">
// Single Page Apps for GitHub Pages
// MIT License
// https://github.com/rafgraph/spa-github-pages
// This script checks to see if a redirect is present in the query string,
// converts it back into the correct url and adds it to the
// browser's history using window.history.replaceState(...),
// which won't cause the browser to attempt to load the new url.
// When the single page app is loaded further down in this file,
// the correct url will be waiting in the browser's history for
// the single page app to route accordingly.
(function(l) {
if (l.search[1] === '/' ) {
var decoded = l.search.slice(1).split('&').map(function(s) {
return s.replace(/~and~/g, '&')
}).join('?');
window.history.replaceState(null, null,
l.pathname.slice(0, -1) + decoded + l.hash
);
}
}(window.location))
</script>
<!-- End Single Page Apps for GitHub Pages -->
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/index.jsx"></script>
</body>
</html>
Loading