Skip to content

Commit

Permalink
draft cropper
Browse files Browse the repository at this point in the history
  • Loading branch information
clbrge committed Jul 27, 2023
1 parent db153c0 commit a90b692
Show file tree
Hide file tree
Showing 6 changed files with 324 additions and 1 deletion.
261 changes: 261 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"add-to-calendar-button": "^1.8.7",
"bulma": "^0.9.4",
"bulma-switch": "^2.0.4",
"cropperjs": "^2.0.0-beta.3",
"eslint": "^8.45.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-svelte": "^2.32.3",
Expand Down
22 changes: 22 additions & 0 deletions src/components/Cropper.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<script>
import { onMount } from 'svelte'
import Cropper from 'cropperjs'
const init = () => {
const image = new Image()
image.src = '/rouge-ticket-black.png'
image.alt = 'Picture'
const cropper = new Cropper(image, {
container: '.cropper-container'
})
console.log(cropper)
}
onMount(init)
</script>

<div class="cropper-container">XXX</div>
2 changes: 1 addition & 1 deletion src/routes/(app)/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@
{#if dev}
<div class="xis-flex-grow-1 has-text-centered">
<span class="icon-text">
<a href="/explorer/">Explorer</a>
<a href="/test/">test</a>
</span>
</div>
<div class="xis-flex-grow-1 has-text-centered">
Expand Down
5 changes: 5 additions & 0 deletions src/routes/(app)/test/+page.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<script>
import Cropper from '$components/Cropper.svelte'
</script>

<Cropper />
34 changes: 34 additions & 0 deletions update-icons.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { promisify } from 'util'
import fs from 'fs'

import { exec as execCallback } from 'child_process'

const exec = promisify(execCallback)

const run = async () => {
const names = []
let output = ''

const { stdout } = await exec(`find src -type f -name *.svelte | xargs cat `)

for await (const line of stdout.split('\n')) {
// non tablers icons
if (/<Icon name="([a-z][a-zA-Z-]*)"/.test(line)) continue
const match = line.match(/<Icon name="([A-Z][a-zA-Z]*)"/)
if (match) {
if (names.includes('Icon' + match[1])) continue
output += `import { Icon${match[1]} } from '@tabler/icons-svelte'\n`
names.push('Icon' + match[1])
} else if (/<Icon/.test(line)) {
if (/{(entry.icon|selector|channel.amount) ?/.test(line)) continue

console.warn('potential unformatted Icon', line)
}
}

output += `\nexport {\n ${names.join(',\n ')}\n}\n`

fs.writeFileSync('src/icons/tabler-icons.js', output)
}

run()

0 comments on commit a90b692

Please sign in to comment.