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

Init SolidJS app Example #14

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"name": "zendesk-vite-boilerplate",
"version": "1.0.0",
"description": "Boilerplate workspace for Zendesk apps",
"main": "index.js",
"workspaces": {
"packages": [
"packages/*"
Expand Down
28 changes: 28 additions & 0 deletions packages/ticket_sidebar/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
## Usage

```bash
$ npm install # or pnpm install or yarn install
```

### Learn more on the [Solid Website](https://solidjs.com) and come chat with us on our [Discord](https://discord.com/invite/solidjs)

## Available Scripts

In the project directory, you can run:

### `npm run dev`

Runs the app in the development mode.<br>
Open [http://localhost:5173](http://localhost:5173) to view it in the browser.

### `npm run build`

Builds the app for production to the `dist` folder.<br>
It correctly bundles Solid in production mode and optimizes the build for the best performance.

The build is minified and the filenames include the hashes.<br>
Your app is ready to be deployed!

## Deployment

Learn more about deploying your application with the [documentations](https://vitejs.dev/guide/static-deploy.html)
7 changes: 4 additions & 3 deletions packages/ticket_sidebar/index.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite App</title>
<title>Vite + Solid + TS</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
<script type="module" src="/src/index.tsx"></script>
</body>
</html>
15 changes: 6 additions & 9 deletions packages/ticket_sidebar/package.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
{
"name": "@app/sidebar",
"name": "ticket_sidebar",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"preview": "vite preview"
},
"dependencies": {
"react": "^18.0.0",
"react-dom": "^18.0.0"
"solid-js": "^1.8.5"
},
"devDependencies": {
"@types/node": "^18.0.0",
"@types/react": "^18.0.0",
"@types/react-dom": "^18.0.0",
"@vitejs/plugin-react": "^1.3.0",
"typescript": "^4.6.3",
"vite": "^2.9.9"
"typescript": "^5.2.2",
"vite": "^4.0.0",
"vite-plugin-solid": "^2.7.2"
}
}
1 change: 1 addition & 0 deletions packages/ticket_sidebar/public/vite.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
49 changes: 17 additions & 32 deletions packages/ticket_sidebar/src/App.css
Original file line number Diff line number Diff line change
@@ -1,42 +1,27 @@
.App {
#root {
max-width: 1280px;
margin: 0 auto;
padding: 2rem;
text-align: center;
}

.App-logo {
height: 40vmin;
pointer-events: none;
.logo {
height: 6em;
padding: 1.5em;
will-change: filter;
transition: filter 300ms;
}

@media (prefers-reduced-motion: no-preference) {
.App-logo {
animation: App-logo-spin infinite 20s linear;
}
}

.App-header {
background-color: #282c34;
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
font-size: calc(10px + 2vmin);
color: white;
.logo:hover {
filter: drop-shadow(0 0 2em #646cffaa);
}

.App-link {
color: #61dafb;
.logo.solid:hover {
filter: drop-shadow(0 0 2em #61dafbaa);
}

@keyframes App-logo-spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
.card {
padding: 2em;
}

button {
font-size: calc(10px + 2vmin);
.read-the-docs {
color: #888;
}
66 changes: 27 additions & 39 deletions packages/ticket_sidebar/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,47 +1,35 @@
import React from "react";
import logo from "./logo.svg";
import "./App.css";
import zafClient from "@app/zendesk/sdk";
import { createSignal } from 'solid-js'
import solidLogo from './assets/solid.svg'
import viteLogo from '/vite.svg'
import './App.css'

function App() {
const [assignee, setAssignee] = React.useState("");

const setTicketAssignee = async () => {
const { ticket } = await zafClient.get("ticket");
setAssignee(ticket.assignee.user.name || "Someone awesome!");
};

React.useEffect(() => {
setTicketAssignee();
}, []);
const [count, setCount] = createSignal(0)

return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<p>Hello {assignee}!</p>
<>
<div>
<a href="https://vitejs.dev" target="_blank">
<img src={viteLogo} class="logo" alt="Vite logo" />
</a>
<a href="https://solidjs.com" target="_blank">
<img src={solidLogo} class="logo solid" alt="Solid logo" />
</a>
</div>
<h1>Vite + Solid</h1>
<div class="card">
<button onClick={() => setCount((count) => count + 1)}>
count is {count()}
</button>
<p>
<a
className="App-link"
href="https://reactjs.org"
target="_blank"
rel="noopener noreferrer"
>
Learn React
</a>
{" | "}
<a
className="App-link"
href="https://vitejs.dev/guide/features.html"
target="_blank"
rel="noopener noreferrer"
>
Vite Docs
</a>
Edit <code>src/App.tsx</code> and save to test HMR
</p>
</header>
</div>
);
</div>
<p class="read-the-docs">
Click on the Vite and Solid logos to learn more
</p>
</>
)
}

export default App;
export default App
1 change: 1 addition & 0 deletions packages/ticket_sidebar/src/assets/solid.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 0 additions & 15 deletions packages/ticket_sidebar/src/favicon.svg

This file was deleted.

71 changes: 63 additions & 8 deletions packages/ticket_sidebar/src/index.css
Original file line number Diff line number Diff line change
@@ -1,13 +1,68 @@
body {
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
sans-serif;
:root {
font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
line-height: 1.5;
font-weight: 400;

color-scheme: light dark;
color: rgba(255, 255, 255, 0.87);
background-color: #242424;

font-synthesis: none;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}

code {
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
monospace;
a {
font-weight: 500;
color: #646cff;
text-decoration: inherit;
}
a:hover {
color: #535bf2;
}

body {
margin: 0;
display: flex;
place-items: center;
min-width: 320px;
min-height: 100vh;
}

h1 {
font-size: 3.2em;
line-height: 1.1;
}

button {
border-radius: 8px;
border: 1px solid transparent;
padding: 0.6em 1.2em;
font-size: 1em;
font-weight: 500;
font-family: inherit;
background-color: #1a1a1a;
cursor: pointer;
transition: border-color 0.25s;
}
button:hover {
border-color: #646cff;
}
button:focus,
button:focus-visible {
outline: 4px auto -webkit-focus-ring-color;
}

@media (prefers-color-scheme: light) {
:root {
color: #213547;
background-color: #ffffff;
}
a:hover {
color: #747bff;
}
button {
background-color: #f9f9f9;
}
}
9 changes: 9 additions & 0 deletions packages/ticket_sidebar/src/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/* @refresh reload */
import { render } from 'solid-js/web'

import './index.css'
import App from './App'

const root = document.getElementById('root')

render(() => <App />, root!)
7 changes: 0 additions & 7 deletions packages/ticket_sidebar/src/logo.svg

This file was deleted.

10 changes: 0 additions & 10 deletions packages/ticket_sidebar/src/main.tsx

This file was deleted.

25 changes: 15 additions & 10 deletions packages/ticket_sidebar/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
{
"compilerOptions": {
"target": "ESNext",
"target": "ES2020",
"useDefineForClassFields": true,
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"allowJs": false,
"skipLibCheck": true,
"esModuleInterop": false,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "ESNext",
"moduleResolution": "Node",
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"skipLibCheck": true,

/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx"
"jsx": "preserve",
"jsxImportSource": "solid-js",

/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
},
"include": ["src"],
"references": [{ "path": "./tsconfig.node.json" }]
Expand Down
6 changes: 4 additions & 2 deletions packages/ticket_sidebar/tsconfig.node.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
{
"compilerOptions": {
"composite": true,
"module": "esnext",
"moduleResolution": "node"
"skipLibCheck": true,
"module": "ESNext",
"moduleResolution": "bundler",
"allowSyntheticDefaultImports": true
},
"include": ["vite.config.ts"]
}
Loading