Skip to content

Commit

Permalink
feat(templates): add new asset javascript template
Browse files Browse the repository at this point in the history
  • Loading branch information
ruidias-commercetools committed Jul 10, 2024
1 parent 1f4f7ab commit dd78e46
Show file tree
Hide file tree
Showing 11 changed files with 843 additions and 5 deletions.
4 changes: 4 additions & 0 deletions application-templates/javascript/assets/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
build/
.nvmrc
public/
21 changes: 21 additions & 0 deletions application-templates/javascript/assets/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 2020,
},
plugins: ['@typescript-eslint'],
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended'],
rules: {
'@typescript-eslint/no-unused-vars': 'error',
'no-undef': 'error',
'no-console': 'error',
'no-const-assign': 'error',
},
env: {
es6: true,
jest: true,
node: true, //adds things like process to global
browser: true
},
};
25 changes: 25 additions & 0 deletions application-templates/javascript/assets/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local
public/

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
17 changes: 17 additions & 0 deletions application-templates/javascript/assets/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/assets/static/commercetools.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="/src/index.css">
<title>Connect Asset</title>
</head>
<body>
<div>
<h3> Connect Asset Application Template </h3>
<a href="https://docs.commercetools.com/connect/" target="_blank"></a>
</div>
<script type="module" src="/src/main.js"></script>
</body>
</html>
27 changes: 27 additions & 0 deletions application-templates/javascript/assets/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "assets",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite --port 3000",
"start": "serve public -l 8080 --cors",
"test": "jest --detectOpenHandles",
"build": "vite build",
"preview": "vite preview",
"serve": "npm run build && serve public -l 3000 --cors",
"lint": "eslint . --ext .ts"
},
"dependencies": {
"serve": "14.2.3"
},
"devDependencies": {
"eslint": "^8.57.0",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-import": "2.29.1",
"eslint-plugin-prettier": "5.1.3",
"eslint-plugin-unused-imports": "3.2.0",
"vite": "5.3.3",
"vite-plugin-css-injected-by-js": "^3.5.1"
}
}
115 changes: 115 additions & 0 deletions application-templates/javascript/assets/src/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
: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;
}

a {
font-weight: 500;
color: #646cff;
text-decoration: inherit;
}
a:hover {
color: #535bf2;
}

body {
margin: 0;
display: flex;
justify-content: center; /* Center horizontally */
align-items: center; /* Center vertically */
min-width: 320px;
min-height: 100vh;
text-align: center; /* Ensure text is centered */
}

h1 {
font-size: 3.6em; /* Increase the size of the text */
line-height: 1.1;
margin: 0.5em 0; /* Add margin for spacing */
}

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, background-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;
}
}

#root {
max-width: 1280px;
margin: 0 auto;
padding: 2rem;
text-align: center;
}

.logo {
padding: 1.5em;
will-change: filter;
transition: filter 300ms;
}
.logo:hover {
filter: drop-shadow(0 0 2em #646cffaa);
}
.logo.react:hover {
filter: drop-shadow(0 0 2em #61dafbaa);
}

@keyframes logo-spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}

@media (prefers-reduced-motion: no-preference) {
a:nth-of-type(2) .logo {
animation: logo-spin infinite 20s linear;
}
}

.card {
padding: 2em;
margin: 1em 0; /* Add margin for spacing */
}

.read-the-docs {
color: #888;
font-size: 0.9em; /* Slightly smaller text */
}
20 changes: 20 additions & 0 deletions application-templates/javascript/assets/src/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import commercetoolsLogo from '../static/commercetools.svg';

export const alertMessage = () => {
alert('Hello! You are now using the Connect Asset Application template!');
};

// Get the anchor tag and set the image source
document.addEventListener('DOMContentLoaded', () => {
const imgElement = document.createElement('img');
imgElement.src = commercetoolsLogo;
imgElement.className = 'logo';
imgElement.alt = 'CT logo';

const linkElement = document.querySelector('a');
if (linkElement) {
linkElement.appendChild(imgElement);
}
});

setTimeout(alertMessage, 1000);
143 changes: 143 additions & 0 deletions application-templates/javascript/assets/static/commercetools.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit dd78e46

Please sign in to comment.