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

[Major] Svelte 5 Migration #78

Merged
merged 12 commits into from
Dec 11, 2024
Merged
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
19 changes: 19 additions & 0 deletions .changeset/stupid-carrots-sin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
"graph-image": major
---

Svelte 5 Runes Upgrade

- Updated Package to use new Svelte 5 runes syntax
- Updated code to use Svelte Actions for client side only code.
- Added `layout` parameter for `Image` for more options of how the image is displayed on the page
- Updated all dependencies
- Updated srcset algorithm to pick more common device sizes and also support larger devices.
- You can now pass all HTML Image attributes & events to the `Image` & `GraphImage` component.
- FadeIn for image is now purely CSS you can edit the transition property with css variable `--graph-image-transition`


## Breaking Changes

- `center` prop has been removed please use `layout` = `fullWidth` instead
- `maxWidth` prop has been removed. Use `layout` = `constrained` (default) and set the width to the dersired maxWidth of the image
13 changes: 0 additions & 13 deletions demo/.eslintignore

This file was deleted.

30 changes: 0 additions & 30 deletions demo/.eslintrc.cjs

This file was deleted.

15 changes: 2 additions & 13 deletions demo/.prettierignore
Original file line number Diff line number Diff line change
@@ -1,15 +1,4 @@
.DS_Store
node_modules
/build
/.svelte-kit
/package
.env
.env.*
!.env.example

# Ignore files for PNPM, NPM and YARN
pnpm-lock.yaml
# Package Managers
package-lock.json
pnpm-lock.yaml
yarn.lock

*.md
10 changes: 9 additions & 1 deletion demo/.prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,13 @@
"singleQuote": true,
"trailingComma": "none",
"printWidth": 100,
"overrides": [{ "files": "**/*.svelte", "options": { "parser": "svelte" } }]
"plugins": ["prettier-plugin-svelte"],
"overrides": [
{
"files": "*.svelte",
"options": {
"parser": "svelte"
}
}
]
}
3 changes: 2 additions & 1 deletion demo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ pnpm dev
The demo site should now be running on your local machine.

## Contributing

We welcome contributions! Please see the main repository for more detail.

## License
Expand All @@ -63,4 +64,4 @@ If you have any questions, feel free to reach out to us at [graphimage@obiemunoz

## Acknowledgements

Thanks to all contributors who have helped to improve this project.
Thanks to all contributors who have helped to improve this project.
33 changes: 33 additions & 0 deletions demo/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import prettier from 'eslint-config-prettier';
import js from '@eslint/js';
import svelte from 'eslint-plugin-svelte';
import globals from 'globals';
import ts from 'typescript-eslint';

export default ts.config(
js.configs.recommended,
...ts.configs.recommended,
...svelte.configs['flat/recommended'],
prettier,
...svelte.configs['flat/prettier'],
{
languageOptions: {
globals: {
...globals.browser,
...globals.node
}
}
},
{
files: ['**/*.svelte'],

languageOptions: {
parserOptions: {
parser: ts.parser
}
}
},
{
ignores: ['build/', '.svelte-kit/', 'dist/']
}
);
37 changes: 19 additions & 18 deletions demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,31 +18,32 @@
"dev": "vite dev",
"build": "vite build",
"preview": "vite preview",
"package": "svelte-kit sync && svelte-package && publint",
"prepublishOnly": "npm run package",
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
"lint": "prettier --plugin=prettier-plugin-svelte --check . && eslint .",
"format": "prettier --plugin=prettier-plugin-svelte --write ."
},
"devDependencies": {
"@sveltejs/adapter-auto": "^2.1.1",
"@sveltejs/kit": "^1.27.7",
"@sveltejs/package": "^2.2.3",
"@typescript-eslint/eslint-plugin": "^6.13.2",
"@typescript-eslint/parser": "^6.13.2",
"eslint": "^8.55.0",
"typescript": "^5.7.2",
"@sveltejs/kit": "^2.10.1",
"svelte": "^5.5.2",
"@sveltejs/package": "^2.3.7",
"@sveltejs/adapter-auto": "^3.3.1",
"@sveltejs/vite-plugin-svelte": "^5.0.1",
"vite": "^6.0.3",
"tslib": "^2.8.1",
"vitest": "^2.1.6",
"eslint": "^9.7.0",
"@types/eslint": "^9.6.0",
"typescript-eslint": "^8.0.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-svelte": "^2.35.1",
"prettier": "^3.1.0",
"prettier-plugin-svelte": "^3.1.2",
"publint": "^0.2.6",
"svelte": "^4.2.8",
"svelte-check": "^3.6.2",
"tslib": "^2.6.2",
"typescript": "^5.3.2",
"vite": "^5.0.13",
"vitest": "^1.0.1"
"eslint-plugin-svelte": "^2.36.0",
"globals": "^15.0.0",
"svelte-check": "^4.1.0",
"prettier": "^3.4.1",
"prettier-plugin-svelte": "^3.3.2",
"publint": "^0.2.6"
},
"dependencies": {
"@graphql-typed-document-node/core": "^3.2.0",
Expand All @@ -52,4 +53,4 @@
"graphql-request": "^6.1.0"
},
"type": "module"
}
}
6 changes: 5 additions & 1 deletion demo/src/lib/Banner/Banner.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
<script lang="ts">
import { GraphImage, GraphImageTypes } from 'graph-image';

export let logo: GraphImageTypes.GraphAsset;
interface Props {
logo: GraphImageTypes.GraphAsset;
}

let { logo }: Props = $props();
</script>

<div class="banner">
Expand Down
12 changes: 8 additions & 4 deletions demo/src/routes/+layout.svelte
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
<script>
<script lang="ts">
import { dev } from '$app/environment';
import { inject } from '@vercel/analytics';
import '../app.css';
interface Props {
children?: import('svelte').Snippet;
}

let { children }: Props = $props();

inject({ mode: dev ? 'development' : 'production' });
</script>

<main>
<div>
<slot />
{@render children?.()}
</div>
</main>

<style>
@import '../app.css';

main {
background-color: #1e1e1e;
color: #f0f0f0;
Expand Down
5 changes: 3 additions & 2 deletions demo/src/routes/+page.server.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import type { PageServerLoad } from './$types';
import { HYGRAPH_TOKEN, HYGRAPH_URL } from '$env/static/private';
import type { TypedDocumentNode } from '@graphql-typed-document-node/core';
import type { GraphImageTypes } from 'graph-image';

import { HYGRAPH_TOKEN, HYGRAPH_URL } from '$env/static/private';
import { GraphQLClient, gql } from 'graphql-request';
import { parse } from 'graphql';
import type { TypedDocumentNode } from '@graphql-typed-document-node/core';

export const load: PageServerLoad = async ({ fetch }) => {
const client = new GraphQLClient(HYGRAPH_URL, {
Expand Down
7 changes: 5 additions & 2 deletions demo/src/routes/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
import { GraphImage } from 'graph-image';
import type { PageData } from './$types.js';

export let data: PageData;
interface Props {
data: PageData;
}

let { data }: Props = $props();

const logo = data.logo;
const headline = data.headline;
Expand Down Expand Up @@ -60,7 +64,6 @@
image={{ ...image, width: 590, height: 331 }}
fit="clip"
withWebp
maxWidth={1200}
/>
</div>
{/each}
Expand Down
2 changes: 1 addition & 1 deletion demo/svelte.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import adapter from '@sveltejs/adapter-auto';
import { vitePreprocess } from '@sveltejs/kit/vite';
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';

/** @type {import('@sveltejs/kit').Config} */
const config = {
Expand Down
13 changes: 0 additions & 13 deletions graph-image/.eslintignore

This file was deleted.

34 changes: 0 additions & 34 deletions graph-image/.eslintrc.cjs

This file was deleted.

15 changes: 2 additions & 13 deletions graph-image/.prettierignore
Original file line number Diff line number Diff line change
@@ -1,15 +1,4 @@
.DS_Store
node_modules
/build
/.svelte-kit
/package
.env
.env.*
!.env.example

# Ignore files for PNPM, NPM and YARN
pnpm-lock.yaml
# Package Managers
package-lock.json
pnpm-lock.yaml
yarn.lock

*.md
10 changes: 9 additions & 1 deletion graph-image/.prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,13 @@
"singleQuote": true,
"trailingComma": "none",
"printWidth": 100,
"overrides": [{ "files": "**/*.svelte", "options": { "parser": "svelte" } }]
"plugins": ["prettier-plugin-svelte"],
"overrides": [
{
"files": "*.svelte",
"options": {
"parser": "svelte"
}
}
]
}
Loading
Loading