Initial commit
Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
21
.gitignore
vendored
Normal file
21
.gitignore
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
node_modules
|
||||
|
||||
# Output
|
||||
.output
|
||||
.vercel
|
||||
/.svelte-kit
|
||||
/build
|
||||
|
||||
# OS
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
|
||||
# Env
|
||||
.env
|
||||
.env.*
|
||||
!.env.example
|
||||
!.env.test
|
||||
|
||||
# Vite
|
||||
vite.config.js.timestamp-*
|
||||
vite.config.ts.timestamp-*
|
4
.prettierignore
Normal file
4
.prettierignore
Normal file
@@ -0,0 +1,4 @@
|
||||
# Package Managers
|
||||
package-lock.json
|
||||
pnpm-lock.yaml
|
||||
yarn.lock
|
17
.prettierrc
Normal file
17
.prettierrc
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"useTabs": false,
|
||||
"tabWidth": 2,
|
||||
"semi": true,
|
||||
"singleQuote": true,
|
||||
"trailingComma": "all",
|
||||
"printWidth": 100,
|
||||
"plugins": ["prettier-plugin-svelte"],
|
||||
"overrides": [
|
||||
{
|
||||
"files": "*.svelte",
|
||||
"options": {
|
||||
"parser": "svelte"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
94
README.md
94
README.md
@@ -1,93 +1,3 @@
|
||||
# Juno
|
||||
# juno
|
||||
|
||||
|
||||
|
||||
## Getting started
|
||||
|
||||
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
|
||||
|
||||
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
|
||||
|
||||
## Add your files
|
||||
|
||||
- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
|
||||
- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
|
||||
|
||||
```
|
||||
cd existing_repo
|
||||
git remote add origin https://git.karaolidis.com/karaolidis/juno.git
|
||||
git branch -M main
|
||||
git push -uf origin main
|
||||
```
|
||||
|
||||
## Integrate with your tools
|
||||
|
||||
- [ ] [Set up project integrations](https://git.karaolidis.com/karaolidis/juno/-/settings/integrations)
|
||||
|
||||
## Collaborate with your team
|
||||
|
||||
- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
|
||||
- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
|
||||
- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
|
||||
- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
|
||||
- [ ] [Set auto-merge](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
|
||||
|
||||
## Test and Deploy
|
||||
|
||||
Use the built-in continuous integration in GitLab.
|
||||
|
||||
- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html)
|
||||
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing (SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
|
||||
- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
|
||||
- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
|
||||
- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
|
||||
|
||||
***
|
||||
|
||||
# Editing this README
|
||||
|
||||
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thanks to [makeareadme.com](https://www.makeareadme.com/) for this template.
|
||||
|
||||
## Suggestions for a good README
|
||||
|
||||
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
|
||||
|
||||
## Name
|
||||
Choose a self-explaining name for your project.
|
||||
|
||||
## Description
|
||||
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
|
||||
|
||||
## Badges
|
||||
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
|
||||
|
||||
## Visuals
|
||||
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
|
||||
|
||||
## Installation
|
||||
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
|
||||
|
||||
## Usage
|
||||
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
|
||||
|
||||
## Support
|
||||
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
|
||||
|
||||
## Roadmap
|
||||
If you have ideas for releases in the future, it is a good idea to list them in the README.
|
||||
|
||||
## Contributing
|
||||
State if you are open to contributions and what your requirements are for accepting them.
|
||||
|
||||
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
|
||||
|
||||
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
|
||||
|
||||
## Authors and acknowledgment
|
||||
Show your appreciation to those who have contributed to the project.
|
||||
|
||||
## License
|
||||
For open source projects, say how it is licensed.
|
||||
|
||||
## Project status
|
||||
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
|
||||
A photography portfolio powered by Svelte.
|
||||
|
33
eslint.config.js
Normal file
33
eslint.config.js
Normal file
@@ -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/'],
|
||||
},
|
||||
);
|
35
package.json
Normal file
35
package.json
Normal file
@@ -0,0 +1,35 @@
|
||||
{
|
||||
"name": "juno",
|
||||
"version": "0.0.1",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite dev",
|
||||
"build": "vite build",
|
||||
"preview": "vite preview",
|
||||
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
|
||||
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
|
||||
"format": "prettier --write .",
|
||||
"lint": "prettier --check . && eslint ."
|
||||
},
|
||||
"devDependencies": {
|
||||
"@sveltejs/adapter-auto": "^3.0.0",
|
||||
"@sveltejs/kit": "^2.5.27",
|
||||
"@sveltejs/vite-plugin-svelte": "^4.0.0",
|
||||
"@types/eslint": "^9.6.0",
|
||||
"eslint": "^9.7.0",
|
||||
"eslint-config-prettier": "^9.1.0",
|
||||
"eslint-plugin-svelte": "^2.45.1",
|
||||
"globals": "^15.0.0",
|
||||
"prettier": "^3.3.2",
|
||||
"prettier-plugin-svelte": "^3.2.6",
|
||||
"svelte": "^5.0.0",
|
||||
"svelte-check": "^4.0.0",
|
||||
"typescript": "^5.5.0",
|
||||
"typescript-eslint": "^8.0.0",
|
||||
"vite": "^5.4.4"
|
||||
},
|
||||
"dependencies": {
|
||||
"exifr": "^7.1.3",
|
||||
"sharp": "^0.33.5"
|
||||
}
|
||||
}
|
13
src/app.d.ts
vendored
Normal file
13
src/app.d.ts
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
// See https://svelte.dev/docs/kit/types#app.d.ts
|
||||
// for information about these interfaces
|
||||
declare global {
|
||||
namespace App {
|
||||
// interface Error {}
|
||||
// interface Locals {}
|
||||
// interface PageData {}
|
||||
// interface PageState {}
|
||||
// interface Platform {}
|
||||
}
|
||||
}
|
||||
|
||||
export {};
|
12
src/app.html
Normal file
12
src/app.html
Normal file
@@ -0,0 +1,12 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<link rel="icon" href="%sveltekit.assets%/favicon.png" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
%sveltekit.head%
|
||||
</head>
|
||||
<body data-sveltekit-preload-data="hover">
|
||||
<div style="display: contents">%sveltekit.body%</div>
|
||||
</body>
|
||||
</html>
|
59
src/lib/components/Gallery.svelte
Normal file
59
src/lib/components/Gallery.svelte
Normal file
@@ -0,0 +1,59 @@
|
||||
<script>
|
||||
import { onMount } from 'svelte';
|
||||
import Masonry from './Masonry.svelte';
|
||||
import debounce from '$lib/utils/debounce';
|
||||
import generatePhotos from '$lib/utils/picsum';
|
||||
|
||||
const pageSize = 10;
|
||||
|
||||
let data = $state([]);
|
||||
let page = 0;
|
||||
let masonry;
|
||||
|
||||
const loadPhotos = () => {
|
||||
data = [...data, ...generatePhotos(pageSize, page * pageSize)];
|
||||
page += 1;
|
||||
};
|
||||
|
||||
onMount(() => {
|
||||
loadPhotos();
|
||||
|
||||
const sentinel = document.querySelector('#sentinel');
|
||||
const loadMoreObserver = new IntersectionObserver(
|
||||
debounce(([entry]) => {
|
||||
if (entry.isIntersecting) loadPhotos();
|
||||
}, 300),
|
||||
);
|
||||
loadMoreObserver.observe(sentinel);
|
||||
});
|
||||
</script>
|
||||
|
||||
<div id="gallery">
|
||||
<Masonry items={data} bind:this={masonry}>
|
||||
{#each data as photo}
|
||||
<img class="photo" src={photo.src} alt={photo.alt} onload={() => masonry?.refresh()} />
|
||||
{/each}
|
||||
</Masonry>
|
||||
<div id="sentinel"></div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
#gallery {
|
||||
width: min(100%, 1200px);
|
||||
}
|
||||
|
||||
.photo {
|
||||
width: 100%;
|
||||
height: auto;
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
overflow: hidden;
|
||||
border-radius: 0.25rem;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
#sentinel {
|
||||
height: 50px;
|
||||
visibility: hidden;
|
||||
}
|
||||
</style>
|
83
src/lib/components/Masonry.svelte
Normal file
83
src/lib/components/Masonry.svelte
Normal file
@@ -0,0 +1,83 @@
|
||||
<script>
|
||||
import { onMount, tick } from 'svelte';
|
||||
|
||||
let { items = [], children } = $props();
|
||||
|
||||
let masonry = $state();
|
||||
let grid;
|
||||
|
||||
const refreshLayout = () => {
|
||||
const newColumnCount = getComputedStyle(grid.element).gridTemplateColumns.split(' ').length;
|
||||
let needsUpdate = grid.columnCount !== newColumnCount;
|
||||
|
||||
grid.items.forEach((item) => {
|
||||
const newHeight = item.getBoundingClientRect().height;
|
||||
|
||||
if (newHeight !== Number(item.dataset.h)) {
|
||||
item.dataset.h = newHeight;
|
||||
needsUpdate = true;
|
||||
}
|
||||
});
|
||||
|
||||
if (!needsUpdate) return;
|
||||
|
||||
grid.columnCount = newColumnCount;
|
||||
grid.items.forEach((item) => item.style.removeProperty('margin-top'));
|
||||
|
||||
if (grid.columnCount === 1) return;
|
||||
|
||||
grid.items.slice(grid.columnCount).forEach((item, i) => {
|
||||
const prevItemBottom = grid.items[i].getBoundingClientRect().bottom;
|
||||
const currentItemTop = item.getBoundingClientRect().top;
|
||||
const offset = prevItemBottom + grid.gap - currentItemTop;
|
||||
|
||||
item.style.marginTop = `${offset}px`;
|
||||
});
|
||||
};
|
||||
|
||||
const initGrid = (element) => ({
|
||||
element,
|
||||
gap: parseFloat(getComputedStyle(element).gridRowGap),
|
||||
items: [...element.childNodes].filter(
|
||||
(child) => child.nodeType === 1 && Number(getComputedStyle(child).gridColumnEnd) !== -1,
|
||||
),
|
||||
columnCount: 0,
|
||||
});
|
||||
|
||||
const calcGrid = async (masonry) => {
|
||||
await tick();
|
||||
if (getComputedStyle(masonry).gridTemplateRows === 'masonry') return;
|
||||
grid = initGrid(masonry);
|
||||
refreshLayout();
|
||||
};
|
||||
|
||||
onMount(() => {
|
||||
window.addEventListener('resize', refreshLayout, false);
|
||||
return () => window.removeEventListener('resize', refreshLayout, false);
|
||||
});
|
||||
|
||||
$effect(() => {
|
||||
if (items) calcGrid(masonry);
|
||||
});
|
||||
|
||||
export const refresh = () => calcGrid(masonry);
|
||||
</script>
|
||||
|
||||
<div bind:this={masonry} class="masonry">
|
||||
{@render children?.()}
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.masonry {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(Min(20em, 100%), 1fr));
|
||||
grid-template-rows: masonry;
|
||||
justify-content: center;
|
||||
grid-gap: 1rem;
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
.masonry > * {
|
||||
align-self: start;
|
||||
}
|
||||
</style>
|
0
src/lib/index.ts
Normal file
0
src/lib/index.ts
Normal file
10
src/lib/utils/debounce.ts
Normal file
10
src/lib/utils/debounce.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
const debounce = (func: Function, wait: number) => {
|
||||
let timeout: number;
|
||||
|
||||
return (...args: any[]) => {
|
||||
clearTimeout(timeout);
|
||||
timeout = setTimeout(() => func(...args), wait);
|
||||
};
|
||||
};
|
||||
|
||||
export default debounce;
|
21
src/lib/utils/picsum.ts
Normal file
21
src/lib/utils/picsum.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
const generatePhotos = (number: number, startId: number) => {
|
||||
const photos = [];
|
||||
|
||||
for (let i = 0; i < number; i++) {
|
||||
const id = startId + i;
|
||||
const width = 200 + Math.floor(Math.random() * 200);
|
||||
const height = 200 + Math.floor(Math.random() * 200);
|
||||
|
||||
photos.push({
|
||||
id,
|
||||
src: `https://picsum.photos/id/${id}/${width}/${height}`,
|
||||
alt: `Photo ${id}`,
|
||||
width,
|
||||
height,
|
||||
});
|
||||
}
|
||||
|
||||
return photos;
|
||||
};
|
||||
|
||||
export default generatePhotos;
|
16
src/routes/+page.svelte
Normal file
16
src/routes/+page.svelte
Normal file
@@ -0,0 +1,16 @@
|
||||
<script>
|
||||
import Gallery from '$lib/components/Gallery.svelte';
|
||||
</script>
|
||||
|
||||
<main>
|
||||
<Gallery />
|
||||
</main>
|
||||
|
||||
<style>
|
||||
main {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
padding: 0.5rem;
|
||||
}
|
||||
</style>
|
13
svelte.config.js
Normal file
13
svelte.config.js
Normal file
@@ -0,0 +1,13 @@
|
||||
import adapter from '@sveltejs/adapter-auto';
|
||||
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
|
||||
|
||||
/** @type {import('@sveltejs/kit').Config} */
|
||||
const config = {
|
||||
preprocess: vitePreprocess(),
|
||||
|
||||
kit: {
|
||||
adapter: adapter(),
|
||||
},
|
||||
};
|
||||
|
||||
export default config;
|
14
tsconfig.json
Normal file
14
tsconfig.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"extends": "./.svelte-kit/tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"allowJs": true,
|
||||
"checkJs": true,
|
||||
"esModuleInterop": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"resolveJsonModule": true,
|
||||
"skipLibCheck": true,
|
||||
"sourceMap": true,
|
||||
"strict": true,
|
||||
"moduleResolution": "bundler"
|
||||
}
|
||||
}
|
6
vite.config.ts
Normal file
6
vite.config.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import { sveltekit } from '@sveltejs/kit/vite';
|
||||
import { defineConfig } from 'vite';
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [sveltekit()],
|
||||
});
|
Reference in New Issue
Block a user