mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2025-08-04 13:30:48 +00:00
Add code style formatting to the website
This commit is contained in:
parent
9f76315bdc
commit
ea0dbd1290
10 changed files with 4477 additions and 39 deletions
8
.vscode/settings.json
vendored
8
.vscode/settings.json
vendored
|
@ -13,6 +13,13 @@
|
||||||
"editor.formatOnSave": true,
|
"editor.formatOnSave": true,
|
||||||
"editor.defaultFormatter": "dbaeumer.vscode-eslint",
|
"editor.defaultFormatter": "dbaeumer.vscode-eslint",
|
||||||
},
|
},
|
||||||
|
"[scss]": {
|
||||||
|
"editor.codeActionsOnSave": {
|
||||||
|
"source.fixAll.eslint": true,
|
||||||
|
},
|
||||||
|
"editor.formatOnSave": true,
|
||||||
|
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
||||||
|
},
|
||||||
// Handlebars: don't save on format
|
// Handlebars: don't save on format
|
||||||
// (`about.hbs` is used by Cargo About to encode license information)
|
// (`about.hbs` is used by Cargo About to encode license information)
|
||||||
"[handlebars]": {
|
"[handlebars]": {
|
||||||
|
@ -26,6 +33,7 @@
|
||||||
"eslint.workingDirectories": [
|
"eslint.workingDirectories": [
|
||||||
"./frontend",
|
"./frontend",
|
||||||
"./bezier-rs/docs/interactive-docs",
|
"./bezier-rs/docs/interactive-docs",
|
||||||
|
"./website",
|
||||||
],
|
],
|
||||||
"eslint.validate": [
|
"eslint.validate": [
|
||||||
"javascript",
|
"javascript",
|
||||||
|
|
85
website/.eslintrc.js
Normal file
85
website/.eslintrc.js
Normal file
|
@ -0,0 +1,85 @@
|
||||||
|
module.exports = {
|
||||||
|
root: true,
|
||||||
|
env: {
|
||||||
|
browser: true,
|
||||||
|
node: true,
|
||||||
|
es2020: true,
|
||||||
|
},
|
||||||
|
parserOptions: {
|
||||||
|
ecmaVersion: 2020,
|
||||||
|
},
|
||||||
|
extends: [
|
||||||
|
// JS defaults
|
||||||
|
"airbnb-base",
|
||||||
|
// General Prettier defaults
|
||||||
|
"prettier",
|
||||||
|
],
|
||||||
|
settings: {
|
||||||
|
// https://github.com/import-js/eslint-plugin-import#resolvers
|
||||||
|
"import/resolver": {
|
||||||
|
// `node` must be listed first!
|
||||||
|
node: {},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
ignorePatterns: [
|
||||||
|
// Ignore generated directories
|
||||||
|
"node_modules/",
|
||||||
|
"public/",
|
||||||
|
|
||||||
|
// Don't ignore JS and TS dotfiles in this folder
|
||||||
|
"!.*.js",
|
||||||
|
"!.*.ts",
|
||||||
|
],
|
||||||
|
plugins: ["prettier"],
|
||||||
|
rules: {
|
||||||
|
// Standard ESLint config
|
||||||
|
indent: "off",
|
||||||
|
quotes: ["error", "double"],
|
||||||
|
camelcase: ["error", { properties: "always" }],
|
||||||
|
"linebreak-style": ["error", "unix"],
|
||||||
|
"eol-last": ["error", "always"],
|
||||||
|
"max-len": ["error", { code: 200, tabWidth: 4 }],
|
||||||
|
"prefer-destructuring": "off",
|
||||||
|
"no-console": "warn",
|
||||||
|
"no-debugger": "warn",
|
||||||
|
"no-param-reassign": ["error", { props: false }],
|
||||||
|
"no-bitwise": "off",
|
||||||
|
"no-shadow": "off",
|
||||||
|
"no-use-before-define": "off",
|
||||||
|
"no-restricted-imports": ["error", { patterns: [".*", "!@/*"] }],
|
||||||
|
|
||||||
|
// Import plugin config (used to intelligently validate module import statements)
|
||||||
|
"import/prefer-default-export": "off",
|
||||||
|
"import/no-relative-packages": "error",
|
||||||
|
"import/order": [
|
||||||
|
"error",
|
||||||
|
{
|
||||||
|
alphabetize: {
|
||||||
|
order: "asc",
|
||||||
|
caseInsensitive: true,
|
||||||
|
},
|
||||||
|
warnOnUnassignedImports: true,
|
||||||
|
"newlines-between": "always-and-inside-groups",
|
||||||
|
pathGroups: [],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
|
||||||
|
// Prettier plugin config (used to enforce HTML, CSS, and JS formatting styles as an ESLint plugin, where fixes are reported to ESLint to be applied when linting)
|
||||||
|
"prettier/prettier": [
|
||||||
|
"error",
|
||||||
|
{
|
||||||
|
tabWidth: 4,
|
||||||
|
tabs: true,
|
||||||
|
printWidth: 200,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
overrides: [
|
||||||
|
{
|
||||||
|
files: ["*.js"],
|
||||||
|
rules: {
|
||||||
|
"@typescript-eslint/explicit-function-return-type": ["off"],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
1
website/.gitignore
vendored
1
website/.gitignore
vendored
|
@ -1 +1,2 @@
|
||||||
|
node_modules/
|
||||||
public/
|
public/
|
||||||
|
|
4327
website/package-lock.json
generated
Normal file
4327
website/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load diff
24
website/package.json
Normal file
24
website/package.json
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
{
|
||||||
|
"name": "graphite-website",
|
||||||
|
"description": "Graphite's website. This npm package is for dev tooling only, such as eslint.",
|
||||||
|
"private": true,
|
||||||
|
"scripts": {},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://github.com/GraphiteEditor/Graphite.git"
|
||||||
|
},
|
||||||
|
"author": "Graphite Authors <contact@graphite.rs>",
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"homepage": "https://graphite.rs",
|
||||||
|
"devDependencies": {
|
||||||
|
"@typescript-eslint/eslint-plugin": "^5.20.0",
|
||||||
|
"@typescript-eslint/parser": "^5.20.0",
|
||||||
|
"eslint": "^8.14.0",
|
||||||
|
"eslint-config-airbnb-base": "^15.0.0",
|
||||||
|
"eslint-config-prettier": "^8.5.0",
|
||||||
|
"eslint-plugin-import": "^2.25.4",
|
||||||
|
"eslint-plugin-prettier": "^4.0.0",
|
||||||
|
"prettier": "^2.6.1",
|
||||||
|
"sass": "^1.50.1"
|
||||||
|
}
|
||||||
|
}
|
|
@ -20,7 +20,7 @@
|
||||||
--font-size-article-h1: 32px;
|
--font-size-article-h1: 32px;
|
||||||
--font-size-article-h2: 24px;
|
--font-size-article-h2: 24px;
|
||||||
--font-size-article-h3: 18px;
|
--font-size-article-h3: 18px;
|
||||||
|
|
||||||
@media screen and (max-width: 760px) {
|
@media screen and (max-width: 760px) {
|
||||||
--font-size-intro-heading: 40px;
|
--font-size-intro-heading: 40px;
|
||||||
--font-size-intro-body: 18px;
|
--font-size-intro-body: 18px;
|
||||||
|
@ -586,7 +586,6 @@ hr,
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,18 +14,18 @@
|
||||||
|
|
||||||
.feed {
|
.feed {
|
||||||
margin-top: -4px;
|
margin-top: -4px;
|
||||||
|
|
||||||
a {
|
a {
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 8px;
|
gap: 8px;
|
||||||
|
|
||||||
.icon {
|
.icon {
|
||||||
vertical-align: top;
|
vertical-align: top;
|
||||||
width: calc(var(--font-size-link) * 1.5);
|
width: calc(var(--font-size-link) * 1.5);
|
||||||
height: calc(var(--font-size-link) * 1.5);
|
height: calc(var(--font-size-link) * 1.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
.link {
|
.link {
|
||||||
vertical-align: top;
|
vertical-align: top;
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,7 @@
|
||||||
max-width: 540px;
|
max-width: 540px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.details {
|
.details {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
@ -92,4 +92,3 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#logo {
|
#logo {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|
||||||
img {
|
img {
|
||||||
width: auto;
|
width: auto;
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
|
@ -27,7 +27,7 @@
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: calc(var(--font-size-link) * 0.8);
|
gap: calc(var(--font-size-link) * 0.8);
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
|
|
||||||
div {
|
div {
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: calc(var(--font-size-link) * 0.8);
|
gap: calc(var(--font-size-link) * 0.8);
|
||||||
|
@ -38,7 +38,6 @@
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#hero-message {
|
#hero-message {
|
||||||
|
@ -250,7 +249,7 @@
|
||||||
width: 100%;
|
width: 100%;
|
||||||
color: var(--color-fog);
|
color: var(--color-fog);
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
|
|
||||||
&:not(:target) {
|
&:not(:target) {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
@ -291,7 +290,6 @@
|
||||||
&.name {
|
&.name {
|
||||||
flex: 1 0 0;
|
flex: 1 0 0;
|
||||||
min-width: 240px;
|
min-width: 240px;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
&.phone {
|
&.phone {
|
||||||
|
@ -378,7 +376,7 @@
|
||||||
width: 48px;
|
width: 48px;
|
||||||
height: 48px;
|
height: 48px;
|
||||||
}
|
}
|
||||||
|
|
||||||
span {
|
span {
|
||||||
line-height: 48px;
|
line-height: 48px;
|
||||||
margin-left: 20px;
|
margin-left: 20px;
|
||||||
|
@ -396,7 +394,7 @@
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 20px;
|
gap: 20px;
|
||||||
|
|
||||||
.headline a {
|
.headline a {
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
color: var(--color-navy);
|
color: var(--color-navy);
|
||||||
|
@ -405,7 +403,7 @@
|
||||||
.publication {
|
.publication {
|
||||||
font-weight: 800;
|
font-weight: 800;
|
||||||
}
|
}
|
||||||
|
|
||||||
.summary {
|
.summary {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
|
|
|
@ -7,7 +7,7 @@ let carouselDirectionNext;
|
||||||
let carouselDots;
|
let carouselDots;
|
||||||
let carouselDescriptions;
|
let carouselDescriptions;
|
||||||
let carouselDragLastClientX;
|
let carouselDragLastClientX;
|
||||||
let velocityDeltaWindow = Array.from({ length: FLING_VELOCITY_WINDOW_SIZE }, () => ({ time: 0, delta: 0 }));
|
const velocityDeltaWindow = Array.from({ length: FLING_VELOCITY_WINDOW_SIZE }, () => ({ time: 0, delta: 0 }));
|
||||||
|
|
||||||
window.addEventListener("DOMContentLoaded", initializeCarousel);
|
window.addEventListener("DOMContentLoaded", initializeCarousel);
|
||||||
window.addEventListener("pointerup", () => dragEnd(false));
|
window.addEventListener("pointerup", () => dragEnd(false));
|
||||||
|
@ -25,15 +25,17 @@ function initializeCarousel() {
|
||||||
carouselDots = document.querySelectorAll(".carousel-controls .dot");
|
carouselDots = document.querySelectorAll(".carousel-controls .dot");
|
||||||
carouselDescriptions = document.querySelectorAll(".screenshot-description p");
|
carouselDescriptions = document.querySelectorAll(".screenshot-description p");
|
||||||
|
|
||||||
carouselDirectionPrev.addEventListener("click", () => slideDirection("prev", false, true));
|
carouselDirectionPrev.addEventListener("click", () => slideDirection("prev", true, false));
|
||||||
carouselDirectionNext.addEventListener("click", () => slideDirection("next", false, true));
|
carouselDirectionNext.addEventListener("click", () => slideDirection("next", true, false));
|
||||||
Array.from(carouselDots).forEach((dot) => dot.addEventListener("click", (event) => {
|
Array.from(carouselDots).forEach((dot) =>
|
||||||
const index = Array.from(carouselDots).indexOf(event.target);
|
dot.addEventListener("click", (event) => {
|
||||||
slideTo(index, true);
|
const index = Array.from(carouselDots).indexOf(event.target);
|
||||||
}));
|
slideTo(index, true);
|
||||||
|
})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function slideDirection(direction, clamped = false, smooth) {
|
function slideDirection(direction, smooth, clamped = false) {
|
||||||
const directionIndexOffset = { prev: -1, next: 1 }[direction];
|
const directionIndexOffset = { prev: -1, next: 1 }[direction];
|
||||||
const offsetDotIndex = currentClosestImageIndex() + directionIndexOffset;
|
const offsetDotIndex = currentClosestImageIndex() + directionIndexOffset;
|
||||||
|
|
||||||
|
@ -53,7 +55,7 @@ function slideTo(index, smooth) {
|
||||||
activeDescription.classList.remove("active");
|
activeDescription.classList.remove("active");
|
||||||
carouselDescriptions[index].classList.add("active");
|
carouselDescriptions[index].classList.add("active");
|
||||||
|
|
||||||
setCurrentTransform(index * -100, "%", smooth)
|
setCurrentTransform(index * -100, "%", smooth);
|
||||||
}
|
}
|
||||||
|
|
||||||
function currentTransform() {
|
function currentTransform() {
|
||||||
|
@ -98,11 +100,11 @@ function dragEnd(dropWithoutVelocity) {
|
||||||
document.querySelector("#screenshots").classList.remove("dragging");
|
document.querySelector("#screenshots").classList.remove("dragging");
|
||||||
|
|
||||||
const onlyRecentVelocityDeltaWindow = velocityDeltaWindow.filter((delta) => delta.time > Date.now() - 1000);
|
const onlyRecentVelocityDeltaWindow = velocityDeltaWindow.filter((delta) => delta.time > Date.now() - 1000);
|
||||||
const timeRange = Date.now() - onlyRecentVelocityDeltaWindow[0]?.time;
|
const timeRange = Date.now() - (onlyRecentVelocityDeltaWindow[0]?.time ?? NaN);
|
||||||
// Weighted (higher by recency) sum of velocity deltas from previous window of frames
|
// Weighted (higher by recency) sum of velocity deltas from previous window of frames
|
||||||
const recentVelocity = onlyRecentVelocityDeltaWindow.reduce((acc, entry) => {
|
const recentVelocity = onlyRecentVelocityDeltaWindow.reduce((acc, entry) => {
|
||||||
const timeSinceNow = Date.now() - entry.time;
|
const timeSinceNow = Date.now() - entry.time;
|
||||||
const recencyFactorScore = 1 - (timeSinceNow / timeRange);
|
const recencyFactorScore = 1 - timeSinceNow / timeRange;
|
||||||
|
|
||||||
return acc + entry.delta * recencyFactorScore;
|
return acc + entry.delta * recencyFactorScore;
|
||||||
}, 0);
|
}, 0);
|
||||||
|
@ -116,15 +118,16 @@ function dragEnd(dropWithoutVelocity) {
|
||||||
if (recentVelocity > 0) {
|
if (recentVelocity > 0) {
|
||||||
// Don't apply the velocity-based fling if we're already snapping to the next image
|
// Don't apply the velocity-based fling if we're already snapping to the next image
|
||||||
if (closestImageIndex >= activeDotIndex) {
|
if (closestImageIndex >= activeDotIndex) {
|
||||||
slideDirection("prev", true, false);
|
slideDirection("prev", false, true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Negative velocity should go to the next image
|
// Negative velocity should go to the next image
|
||||||
else {
|
else {
|
||||||
// Don't apply the velocity-based fling if we're already snapping to the next image
|
// Don't apply the velocity-based fling if we're already snapping to the next image
|
||||||
|
// eslint-disable-next-line no-lonely-if
|
||||||
if (closestImageIndex <= activeDotIndex) {
|
if (closestImageIndex <= activeDotIndex) {
|
||||||
slideDirection("next", true, false);
|
slideDirection("next", false, true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,8 +11,6 @@ let fullRippleHeight;
|
||||||
let ripples;
|
let ripples;
|
||||||
let activeRippleIndex;
|
let activeRippleIndex;
|
||||||
|
|
||||||
let globalCount = 0;
|
|
||||||
|
|
||||||
window.addEventListener("DOMContentLoaded", initializeRipples);
|
window.addEventListener("DOMContentLoaded", initializeRipples);
|
||||||
window.addEventListener("resize", () => animate(true));
|
window.addEventListener("resize", () => animate(true));
|
||||||
|
|
||||||
|
@ -22,7 +20,7 @@ function initializeRipples() {
|
||||||
navButtons = document.querySelectorAll("header nav a");
|
navButtons = document.querySelectorAll("header nav a");
|
||||||
rippleSvg = document.querySelector("header .ripple");
|
rippleSvg = document.querySelector("header .ripple");
|
||||||
ripplePath = rippleSvg.querySelector("path");
|
ripplePath = rippleSvg.querySelector("path");
|
||||||
fullRippleHeight = Number.parseInt(window.getComputedStyle(rippleSvg).height) - 4;
|
fullRippleHeight = Number.parseInt(window.getComputedStyle(rippleSvg).height, 10) - 4;
|
||||||
|
|
||||||
ripples = Array.from(navButtons).map((button) => ({
|
ripples = Array.from(navButtons).map((button) => ({
|
||||||
element: button,
|
element: button,
|
||||||
|
@ -33,7 +31,6 @@ function initializeRipples() {
|
||||||
|
|
||||||
activeRippleIndex = ripples.findIndex((ripple) => ripple.element.getAttribute("href").replace(/\//g, "") === window.location.pathname.replace(/\//g, ""));
|
activeRippleIndex = ripples.findIndex((ripple) => ripple.element.getAttribute("href").replace(/\//g, "") === window.location.pathname.replace(/\//g, ""));
|
||||||
|
|
||||||
|
|
||||||
ripples.forEach((ripple) => {
|
ripples.forEach((ripple) => {
|
||||||
const updateTimings = (goingUp) => {
|
const updateTimings = (goingUp) => {
|
||||||
const start = ripple.animationStartTime;
|
const start = ripple.animationStartTime;
|
||||||
|
@ -66,11 +63,8 @@ function initializeRipples() {
|
||||||
|
|
||||||
function animate(forceRefresh) {
|
function animate(forceRefresh) {
|
||||||
if (!ripplesInitialized) return;
|
if (!ripplesInitialized) return;
|
||||||
|
|
||||||
const animateThisFrame = ripples.some((ripple) => ripple.animationStartTime && ripple.animationEndTime && Date.now() <= ripple.animationEndTime);
|
|
||||||
|
|
||||||
// console.log(globalCount, new Date().getSeconds(), Date.now(), animateThisFrame, {...ripples[0]});
|
const animateThisFrame = ripples.some((ripple) => ripple.animationStartTime && ripple.animationEndTime && Date.now() <= ripple.animationEndTime);
|
||||||
globalCount++;
|
|
||||||
|
|
||||||
if (animateThisFrame || forceRefresh) {
|
if (animateThisFrame || forceRefresh) {
|
||||||
setRipples();
|
setRipples();
|
||||||
|
@ -79,7 +73,7 @@ function animate(forceRefresh) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function setRipples() {
|
function setRipples() {
|
||||||
const navButtonFontSize = Number.parseInt(window.getComputedStyle(navButtons[0]).fontSize) || NAV_BUTTON_INITIAL_FONT_SIZE;
|
const navButtonFontSize = Number.parseInt(window.getComputedStyle(navButtons[0]).fontSize, 10) || NAV_BUTTON_INITIAL_FONT_SIZE;
|
||||||
const mediaQueryScaleFactor = navButtonFontSize / NAV_BUTTON_INITIAL_FONT_SIZE;
|
const mediaQueryScaleFactor = navButtonFontSize / NAV_BUTTON_INITIAL_FONT_SIZE;
|
||||||
|
|
||||||
const rippleHeight = fullRippleHeight * (mediaQueryScaleFactor * 0.5 + 0.5);
|
const rippleHeight = fullRippleHeight * (mediaQueryScaleFactor * 0.5 + 0.5);
|
||||||
|
@ -98,12 +92,12 @@ function setRipples() {
|
||||||
const buttonRect = ripple.element.getBoundingClientRect();
|
const buttonRect = ripple.element.getBoundingClientRect();
|
||||||
|
|
||||||
const buttonCenter = buttonRect.width / 2;
|
const buttonCenter = buttonRect.width / 2;
|
||||||
const rippleCenter = RIPPLE_WIDTH / 2 * mediaQueryScaleFactor;
|
const rippleCenter = (RIPPLE_WIDTH / 2) * mediaQueryScaleFactor;
|
||||||
const rippleOffset = rippleCenter - buttonCenter;
|
const rippleOffset = rippleCenter - buttonCenter;
|
||||||
|
|
||||||
const rippleStartX = buttonRect.left - rippleSvgLeft - rippleOffset;
|
const rippleStartX = buttonRect.left - rippleSvgLeft - rippleOffset;
|
||||||
|
|
||||||
const rippleRadius = RIPPLE_WIDTH / 2 * mediaQueryScaleFactor;
|
const rippleRadius = (RIPPLE_WIDTH / 2) * mediaQueryScaleFactor;
|
||||||
const handleRadius = rippleRadius * HANDLE_STRETCH;
|
const handleRadius = rippleRadius * HANDLE_STRETCH;
|
||||||
|
|
||||||
path += `L ${rippleStartX},${rippleHeight + 3} `;
|
path += `L ${rippleStartX},${rippleHeight + 3} `;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue