Skip to content

Commit

Permalink
Initialize vanilla-extract
Browse files Browse the repository at this point in the history
  • Loading branch information
celinechoiii authored Sep 23, 2024
0 parents commit 64173fe
Show file tree
Hide file tree
Showing 27 changed files with 6,901 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": ["next/core-web-vitals", "next/typescript", "prettier"]
}
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto eol=lf
37 changes: 37 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[//]: # "Feel free to customize this template to your project's vibes"

## What's new in this PR
### Description
[//]: # "Required - Describe what's new in this PR in a few lines. A description and bullet points for specifics will suffice."



### Screenshots
[//]: # "Required for frontend changes, otherwise optional but strongly recommended. Add screenshots of expected behavior - GIFs if you're feeling fancy! Use the provided image template. Drag the desired image into the PR, then copy the link into the placeholder."

[image placeholder]: <img src="place image link here!!!" width="240" height="540">



## How to review
[//]: # 'Required - Describe the order in which to review files and what to expect when testing locally. Is there anything specifically you want feedback on? Should this be reviewed commit by commit, or all at once? What are some user flows to test? What are some edge cases to look out for?'



## Next steps
[//]: # "Optional - What's NOT in this PR, doesn't work yet, and/or still needs to be done. Note any temporary fixes in this PR that should be cleaned up later."



## Relevant links
### Online sources
[//]: # 'Copy links to any tutorials or documentation that was useful to you when working on this PR'



### Related PRs
[//]: # "Add related PRs you're waiting on/ PRs that will conflict, etc; if this is a refactor, feel free to add PRs that previously modified this code"



CC: @insert pl github username here
62 changes: 62 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
---
name: Lint

#############################
# Start the job on push #
#############################
on:
push:
branches-ignore: [main]
pull_request:
branches: [main]

###############
# Set the Job #
###############
jobs:
build:
# Name the Job
name: Run ESLint, Prettier, and TypeScript compiler
# Set the agent to run on
runs-on: ubuntu-latest

##################
# Load all steps #
##################
steps:
##########################
# Checkout the code base #
##########################
- name: Checkout Code
uses: actions/checkout@v4
with:
# Full git history is needed to get a proper
# list of changed files within `super-linter`
fetch-depth: 0

################################
# Install packages #
################################
- name: Install packages
uses: pnpm/action-setup@v4
with:
version: 9
run_install: true

################################
# Lint codebase #
################################
- name: Run ESLint
run: pnpm exec eslint .

################################
# Check Prettier on codebase #
################################
- name: Run Prettier
run: pnpm exec prettier --check .

################################
# Check for TypeScript errors #
################################
- name: Run TypeScript compiler (tsc)
run: pnpm exec tsc --noEmit
36 changes: 36 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js
.yarn/install-state.gz

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# local env files
.env*.local

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts
1 change: 1 addition & 0 deletions .husky/post-checkout
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pnpm exec yarnhook
1 change: 1 addition & 0 deletions .husky/post-merge
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pnpm exec yarnhook
1 change: 1 addition & 0 deletions .husky/post-rewrite
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pnpm exec yarnhook
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pnpm run pre-commit
7 changes: 7 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.github/
.vscode/
.next/

README.md
package-lock.json
next-env.d.ts
24 changes: 24 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"arrowParens": "avoid",
"bracketSameLine": false,
"bracketSpacing": true,
"printWidth": 80,
"semi": true,
"singleQuote": true,
"trailingComma": "all",
"importOrder": [
"<TYPES>^(node:)",
"<TYPES>",
"<TYPES>^[.]",
"^react$",
"^react[-/]{1}.*",
"^next$",
"^next[-/]{1}.*",
"<BUILTIN_MODULES>",
"<THIRD_PARTY_MODULES>",
"^@/.*$",
"^[.]",
"[.]css$"
],
"plugins": ["@ianvs/prettier-plugin-sort-imports"]
}
13 changes: 13 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
// Extension identifier format: ${publisher}.${name}. Example: vscode.csharp

// List of extensions which should be recommended for users of this workspace.
"recommendations": [
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
"eamodio.gitlens"
],
// List of extensions recommended by VS Code that should not be recommended for users of this workspace.
"unwantedRecommendations": []
}
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"editor.formatOnSave": true,
"editor.tabSize": 2
}
78 changes: 78 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# \[Insert Project Name\]

**[BLUEPRINT INTERNAL]: PLEASE GO THROUGH THIS README AND REPLACE ALL THE [INSERT] STATEMENTS WITH VALUES SPECIFIC TO YOUR PROJECT. DELETE THIS SECTION WHEN DONE.**

This template also has variants with pre-configured setup for styling libraries:
- [Tailwind CSS](https://github.com/calblueprint/web-app-template/tree/tailwind)
- [Styled Components](https://github.com/calblueprint/web-app-template/tree/styled-components)
- [Vanilla Extract](https://github.com/calblueprint/web-app-template/tree/vanilla-extract)

---

This project is being built by a team at [Blueprint](https://calblueprint.org), a student organization at the University of California, Berkeley building software pro bono for nonprofits.

## Getting Started

### Prerequisites

Check your installation of `node` and `pnpm`:

```bash
node -v
pnpm -v
```

We strongly recommend using a Node version manager like [nvm](https://github.com/nvm-sh/nvm) (for Mac) or [nvm-windows](https://github.com/coreybutler/nvm-windows) (for Windows) to install Node.js. If you don't plan on switching between different Node versions, you can alternatively get a [prebuilt installer](https://nodejs.org/en/download/prebuilt-installer) from the Node.js website for an easier approach. Make sure to get Node version 18 and up, the latest LTS version should be sufficient.

After installing Node, you most likely have npm installed as well (check by running `npm -v`). If you have npm installed, simply run `npm install -g pnpm` to install pnpm. If your command line does not recognize npm as a command, refer to [this article](https://www.geeksforgeeks.org/how-to-resolve-npm-command-not-found-error-in-node-js/) to troubleshoot.

Additional resources:
- [Downloading and installing Node.js and npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm)
- [Installing pnpm without npm](https://pnpm.io/installation)

### Installation

1. Clone the repo & install dependencies

1. Clone this repo
- using SSH (recommended)
```bash
git clone [git@insert-project-ssh]
```
- using HTTPS
```bash
git clone [insert.project.link]
```
2. Enter the cloned directory
```bash
cd [insert-project-repo]
```
3. Install project dependencies. This command installs all packages from [`package.json`](package.json).
```bash
pnpm install
```

2. Set up secrets:
1. In the project's root directory (`[insert-project-repo]/`), create a new file named `.env.local`
2. Copy the credentials from [Blueprint's internal Notion](https://www.notion.so/calblueprint/Environment-Setup-6fb1e251cdca4393b9dd47a3436abc11?pvs=4#9c2ff603f7a44348835c97e96d521d2d) (access is required) and paste them into the `.env.local` file.

**Helpful resources**

- [GitHub: Cloning a Repository](https://docs.github.com/en/repositories/creating-and-managing-repositories/cloning-a-repository#cloning-a-repository)
- [GitHub: Generating SSH keys](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent)

### Development environment

- **[VSCode](https://code.visualstudio.com/) (recommended)**
1. Open the `[insert-project-repo]` project in VSCode.
2. Install recommended workspace VSCode extensions. You should see a pop-up on the bottom right to "install the recommended extensions for this repository".

### Running the app

In the project directory, run:

```shell
pnpm dev
```

Then, navigate to http://localhost:3000 to launch the web application.
Binary file added app/favicon.ico
Binary file not shown.
26 changes: 26 additions & 0 deletions app/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import type { Metadata } from 'next';
import { Inter } from 'next/font/google';

// font definitions
const sans = Inter({
variable: '--font-sans',
subsets: ['latin'],
});

// site metadata - what shows up on embeds
export const metadata: Metadata = {
title: 'Project Name',
description: 'Description of project',
};

export default function RootLayout({
children,
}: Readonly<{
children: React.ReactNode;
}>) {
return (
<html lang="en">
<body className={sans.className}>{children}</body>
</html>
);
}
16 changes: 16 additions & 0 deletions app/page.css.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { style } from '@vanilla-extract/css';

export const mainStyles = style({
width: '100%',
height: '100svh',
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
justifyContent: 'center',
});

export const imageStyles = style({
width: '80px',
height: '80px',
marginBottom: '0.5rem',
});
12 changes: 12 additions & 0 deletions app/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import Image from 'next/image';
import BPLogo from '@/assets/images/bp-logo.png';
import { imageStyles, mainStyles } from './page.css';

export default function Home() {
return (
<main className={mainStyles}>
<Image className={imageStyles} src={BPLogo} alt="Blueprint Logo" />
<p>Open up app/page.tsx to get started!</p>
</main>
);
}
Binary file added assets/images/bp-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions components/Button.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import React from 'react';

export const Button = React.forwardRef<
HTMLButtonElement,
React.ButtonHTMLAttributes<HTMLButtonElement>
>(({ children, ...props }) => {
return <button {...props}>{children}</button>;
});
Button.displayName = 'Button';
5 changes: 5 additions & 0 deletions graphics.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
declare module '*.png';
declare module '*.svg';
declare module '*.jpeg';
declare module '*.jpg';
declare module '*.webp';
10 changes: 10 additions & 0 deletions lib/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/**
* Random number generator built on top of Math.random().
*
* @param min The minimum value (inclusive)
* @param max The maximum value (inclusive)
* @returns A random number between min and max.
*/
export function random(min: number, max: number): number {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
8 changes: 8 additions & 0 deletions next.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { createVanillaExtractPlugin } from '@vanilla-extract/next-plugin';

const withVanillaExtract = createVanillaExtractPlugin();

/** @type {import('next').NextConfig} */
const nextConfig = {};

export default withVanillaExtract(nextConfig);
Loading

0 comments on commit 64173fe

Please sign in to comment.