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

chore: update frontend templates #4003

Open
wants to merge 38 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
b10447b
chore: update react project template
Nov 18, 2024
b66c069
chore: update svelte template
Nov 18, 2024
515a245
chore: update vanillajs template. rename logo2 --> logo
Nov 18, 2024
fd4ffc2
chore: update vue template. update CSP
Nov 18, 2024
c0f29d1
Merge branch 'master' into update-frontend-templates
Nov 18, 2024
c02ae96
chore: update templates to fix warnings / errors
Nov 18, 2024
ecbeaa1
chore: update welcome message
Nov 18, 2024
1c082ff
chore: update outdated warning
Nov 18, 2024
d6c3694
chore: update info message about installing unchecked wasm hash in pl…
Nov 18, 2024
cf7c2d3
Merge branch 'master' into update-frontend-templates
Nov 18, 2024
bb97307
chore: use single quotes
Nov 19, 2024
680c26a
chore: update line numbers in patch
Nov 19, 2024
b2a2702
chore: update line numbers in patch
Nov 19, 2024
719c637
chore: update test snapshots
Nov 19, 2024
5b6b690
chore: update test snapshots
Nov 19, 2024
b56765a
chore: update test snapshots
Nov 19, 2024
d5e15c9
chore: update test snapshots
Nov 19, 2024
47be031
Merge branch 'master' into update-frontend-templates
Nov 20, 2024
c62e88b
Merge branch 'master' into update-frontend-templates
Nov 21, 2024
75db25f
Merge branch 'master' into update-frontend-templates
Nov 29, 2024
5092254
Merge branch 'master' into update-frontend-templates
Dec 5, 2024
d45c964
Update .ic-assets.json5
Dec 5, 2024
f919a65
Update .ic-assets.json5
Dec 5, 2024
29fe469
Update .ic-assets.json5
Dec 5, 2024
f166c05
Update .ic-assets.json5
Dec 5, 2024
67fad0b
Merge branch 'master' into update-frontend-templates
Dec 6, 2024
b4fc2e2
Merge branch 'master' into update-frontend-templates
Dec 10, 2024
b72535f
Merge branch 'master' into update-frontend-templates
Dec 12, 2024
4313608
chore: revert changes to .ic-assets.json5
Dec 12, 2024
c06fb27
chore: remove indentation changes
Dec 13, 2024
9d2bef6
chore: revert
Dec 13, 2024
7709341
chore: fix indentation
Dec 13, 2024
c2a09e3
chore: indent
Dec 13, 2024
e7dd1a2
Merge branch 'master' into update-frontend-templates
Dec 13, 2024
eaa572f
chore: update security policy for compatibility with safari
Dec 18, 2024
3563018
chore: update security policy for compatibility with safari
Dec 18, 2024
472d1f5
Merge branch 'master' into update-frontend-templates
Dec 18, 2024
e94ee76
Merge branch 'master' into update-frontend-templates
Dec 19, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"@types/react-dom": "^18.2.6",
"@vitejs/plugin-react": "^4.0.1",
"dotenv": "^16.3.1",
"sass": "^1.63.6",
"sass": "^1.81.0",
"typescript": "^5.1.3",
"vite": "^4.3.9",
"vite-plugin-environment": "^1.1.3"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,25 @@ import { __backend_name_ident__ } from 'declarations/__backend_name__';
function App() {
const [greeting, setGreeting] = useState('');

function handleSubmit(event) {
async function handleSubmit(event) {
event.preventDefault();
const name = event.target.elements.name.value;
__backend_name_ident__.greet(name).then((greeting) => {
setGreeting(greeting);
});
const greeting = await __backend_name_ident__.greet(name);
setGreeting(greeting);
return false;
}

return (
<main>
<img src="/logo2.svg" alt="DFINITY logo" />
<br />
<br />
<form action="#" onSubmit={handleSubmit}>
<label htmlFor="name">Enter your name: &nbsp;</label>
<input id="name" alt="Name" type="text" />
<button type="submit">Click Me!</button>
</form>
<section id="greeting">{greeting}</section>
<main className="container">
<div className="card">
<h1>{greeting}</h1>
<form action="#" onSubmit={handleSubmit}>
<label htmlFor="name">Enter your name:</label>
<input type="text" id="name" required />
<button type="submit">Click Me!</button>
</form>
<img src="/logo.svg" alt="DFINITY logo" width="256" />
</div>
</main>
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,37 +1,95 @@
body {
font-family: sans-serif;
font-size: 1.5rem;
:root {
--vc-brand-gradient: radial-gradient(at 100% 100%, hsla(265, 80%, 75%, 1) 0px, transparent 50%), radial-gradient(at 100% 0%, hsla(272, 86%, 55%, 1) 0px, transparent 50%), radial-gradient(at 0% 18%, hsla(223, 79%, 66%, 1) 0px, transparent 50%);
--vc-brand-purple: #4b19d6;

--rc-background-image--highlight: var(--vc-brand-gradient);
--rc-background--highlight: var(--vc-brand-purple);

--rc-interaction-color: #4b19d6;
--rc-interaction-color-hover: #3c14aa;
}

img {
max-width: 50vw;
max-height: 25vw;
display: block;
margin: auto;
body, html {
margin: 0;
padding: 0;
font-family: -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
height: 100%;
}

form {
#root {
height: 100%;
}

.container {
min-height: 100%;
display: flex;
justify-content: center;
gap: 0.5em;
flex-flow: row wrap;
max-width: 40vw;
margin: auto;
align-items: baseline;
align-items: center;
background-image: var(--rc-background-image--highlight);
background-color: var(--rc-background--highlight);
}

.card {
background: white;
padding: 2rem;
border-radius: 8px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
width: 100%;
max-width: 320px;
display: flex;
flex-direction: column;
gap: 2rem;
align-items: center;
}

.logo {
text-align: center;
margin-bottom: 1rem;
}

button[type="submit"] {
padding: 5px 20px;
margin: 10px auto;
float: right;
.logo svg {
width: 100px;
height: auto;
}

#greeting {
margin: 10px auto;
padding: 10px 60px;
border: 1px solid #222;
h1 {
color: #333;
text-align: center;
margin: 0 0 1rem;

&:empty {
display: none;
}
}

form {
display: flex;
flex-direction: column;
width: 100%;
}

#greeting:empty {
display: none;
label {
margin-bottom: 0.5rem;
color: #333;
}

input {
padding: 0.5rem;
margin-bottom: 1rem;
border: 1px solid #ccc;
border-radius: 4px;
}

button {
padding: 0.5rem;
background-color: var(--rc-interaction-color);
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
transition: background-color 0.3s;
}

button:hover {
background-color: var(--rc-interaction-color-hover);
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,37 @@ export default defineConfig({
optimizeDeps: {
esbuildOptions: {
define: {
global: "globalThis",
global: 'globalThis',
},
},
},
server: {
proxy: {
"/api": {
target: "http://127.0.0.1:4943",
'/api': {
target: 'http://127.0.0.1:4943',
changeOrigin: true,
},
},
},
plugins: [
react(),
environment("all", { prefix: "CANISTER_" }),
environment("all", { prefix: "DFX_" }),
environment('all', { prefix: 'CANISTER_' }),
environment('all', { prefix: 'DFX_' }),
],
css: {
preprocessorOptions: {
scss: {
api: 'modern-compiler',
silenceDeprecations: ['legacy-js-api'],
},
},
},
resolve: {
alias: [
{
find: "declarations",
find: 'declarations',
replacement: fileURLToPath(
new URL("../declarations", import.meta.url)
new URL('../declarations', import.meta.url),
),
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe('App', () => {
<App />
</StrictMode>,
);
expect(document.body.innerHTML).toMatchInlineSnapshot('"<div><main><img src="/logo2.svg" alt="DFINITY logo"><br><br><form action="#"><label for="name">Enter your name: &nbsp;</label><input id="name" alt="Name" type="text"><button type="submit">Click Me!</button></form><section id="greeting"></section></main></div>"');
expect(document.body.innerHTML).toMatchInlineSnapshot('"<div><main class="container"><div class="card"><h1></h1><form action="#"><label for="name">Enter your name:</label><input type="text" id="name" required=""><button type="submit">Click Me!</button></form><img src="/logo.svg" alt="DFINITY logo" width="256"></div></main></div>"');
expect(1).toEqual(1);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
@@ -1,1 +1,2 @@
+/// <reference types="vitest" />
import { fileURLToPath, URL } from 'url';
@@ -33,1 +33,5 @@
@@ -41,1 +41,5 @@
+ test: {
+ environment: 'jsdom',
+ setupFiles: 'src/setupTests.js',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"@sveltejs/kit": "^2.5.26",
"@sveltejs/vite-plugin-svelte": "^3.1.2",
"dotenv": "^16.3.1",
"sass": "^1.63.6",
"sass": "^1.81.0",
"svelte": "^4.2.19",
"svelte-check": "^4.0.1",
"typescript": "^5.6.2",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,37 +1,95 @@
body {
font-family: sans-serif;
font-size: 1.5rem;
:root {
--vc-brand-gradient: radial-gradient(at 100% 100%, hsla(265, 80%, 75%, 1) 0px, transparent 50%), radial-gradient(at 100% 0%, hsla(272, 86%, 55%, 1) 0px, transparent 50%), radial-gradient(at 0% 18%, hsla(223, 79%, 66%, 1) 0px, transparent 50%);
--vc-brand-purple: #4b19d6;

--rc-background-image--highlight: var(--vc-brand-gradient);
--rc-background--highlight: var(--vc-brand-purple);

--rc-interaction-color: #4b19d6;
--rc-interaction-color-hover: #3c14aa;
}

img {
max-width: 50vw;
max-height: 25vw;
display: block;
margin: auto;
body, html {
margin: 0;
padding: 0;
font-family: -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
height: 100%;
}

form {
#root {
height: 100%;
}

.container {
min-height: 100%;
display: flex;
justify-content: center;
gap: 0.5em;
flex-flow: row wrap;
max-width: 40vw;
margin: auto;
align-items: baseline;
align-items: center;
background-image: var(--rc-background-image--highlight);
background-color: var(--rc-background--highlight);
}

.card {
background: white;
padding: 2rem;
border-radius: 8px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
width: 100%;
max-width: 320px;
display: flex;
flex-direction: column;
gap: 2rem;
align-items: center;
}

.logo {
text-align: center;
margin-bottom: 1rem;
}

button[type="submit"] {
padding: 5px 20px;
margin: 10px auto;
float: right;
.logo svg {
width: 100px;
height: auto;
}

#greeting {
margin: 10px auto;
padding: 10px 60px;
border: 1px solid #222;
h1 {
color: #333;
text-align: center;
margin: 0 0 1rem;

&:empty {
display: none;
}
}

form {
display: flex;
flex-direction: column;
width: 100%;
}

#greeting:empty {
display: none;
label {
margin-bottom: 0.5rem;
color: #333;
}

input {
padding: 0.5rem;
margin-bottom: 1rem;
border: 1px solid #ccc;
border-radius: 4px;
}

button {
padding: 0.5rem;
background-color: var(--rc-interaction-color);
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
transition: background-color 0.3s;
}

button:hover {
background-color: var(--rc-interaction-color-hover);
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,21 @@

let greeting = "";

function onSubmit(event) {
async function onSubmit(event) {
const name = event.target.name.value;
backend.greet(name).then((response) => {
greeting = response;
});
greeting = await backend.greet(name);
return false;
}
</script>

<main>
<img src="/logo2.svg" alt="DFINITY logo" />
<br />
<br />
<form action="#" on:submit|preventDefault={onSubmit}>
<label for="name">Enter your name: &nbsp;</label>
<input id="name" alt="Name" type="text" />
<button type="submit">Click Me!</button>
</form>
<section id="greeting">{greeting}</section>
<main class="container">
<div class="card">
<h1>{greeting}</h1>
<form action="#" on:submit|preventDefault={onSubmit}>
<label for="name">Enter your name:</label>
<input type="text" id="name" required />
<button type="submit">Click Me!</button>
</form>
<img src="/logo.svg" alt="DFINITY logo" width="256" />
</div>
</main>
Loading
Loading