From 3467598e83ed13d26c9b3aca5f77e45a15f4a3fb Mon Sep 17 00:00:00 2001 From: Erik Date: Sun, 8 Sep 2024 19:28:07 +0200 Subject: [PATCH] split css into print and screen and also included a padding option --- .github/workflows/pins.yml | 30 ---- Dockerfile | 15 -- css/print.css | 40 ++++++ css/screen.css | 267 +++++++++++++++++++++++++++++++++++ css/style.css | 281 +++---------------------------------- index.html | 57 +++++--- js/script.js | 149 ++++++++++++-------- 7 files changed, 459 insertions(+), 380 deletions(-) delete mode 100644 .github/workflows/pins.yml delete mode 100644 Dockerfile create mode 100644 css/print.css create mode 100644 css/screen.css diff --git a/.github/workflows/pins.yml b/.github/workflows/pins.yml deleted file mode 100644 index 6fc49c6..0000000 --- a/.github/workflows/pins.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: Pins -on: - push: - branches: [main] - pull_request: - branches: [main] -jobs: - build: - name: Build docker container - runs-on: ubuntu-latest - - permissions: - packages: write - - steps: - - uses: actions/checkout@v3 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - name: Login to GitHub Container Registry - if: ${{ github.ref == 'refs/heads/main' }} - uses: docker/login-action@v2 - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} - - name: Build Docker image (and push on main) - uses: docker/build-push-action@v4.0.0 - with: - push: ${{ github.ref == 'refs/heads/main' }} - tags: ghcr.io/cthit/pins:latest diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index f7848d2..0000000 --- a/Dockerfile +++ /dev/null @@ -1,15 +0,0 @@ -# Use the official Nginx base image -FROM nginx:latest - -# Set the working directory to the Nginx default public directory -WORKDIR /usr/share/nginx/html/ - -# Copy your HTML, CSS, and JS files to the Nginx default public directory -COPY index.html . -COPY css/ css/ -COPY js/ js/ -COPY images/ images/ - - -# Expose port 80 for web traffic -EXPOSE 80 diff --git a/css/print.css b/css/print.css new file mode 100644 index 0000000..7e31bfe --- /dev/null +++ b/css/print.css @@ -0,0 +1,40 @@ + +.image-container, .imageRow { + display: flex; + flex-direction: column; + justify-content: space-between; + align-items: flex-start; + gap: var(--pinSpacing); +} + +.imageRow { + flex-direction: row; +} + +.pinImage { + width: var(--pinSize); + height: var(--pinSize); +} + +.pinImageWithPadding { + width: var(--pinImageSize); + height: var(--pinImageSize); + padding: 5.5mm; + border: .5mm solid #000; + border-radius: var(--pinImageSize); +} + +.pinImageWithBackground { + background-color: var(--printBackgroundColor); +} + + +@media print { + body { + background-color: var(--printBackgroundColor); + } + + .mainContent, footer, #howTo, #showHowToButton { + display: none; + } +} \ No newline at end of file diff --git a/css/screen.css b/css/screen.css new file mode 100644 index 0000000..22400a0 --- /dev/null +++ b/css/screen.css @@ -0,0 +1,267 @@ + +@media only screen { + .showHowToButton { + background: #292929; + + cursor: pointer; + + display: flex; + align-items: center; + justify-content: center; + + position: absolute; + top: 1rem; + right: 1rem; + + width: 3rem; + height: 3rem; + outline: .1rem solid #09cdda; + border-radius: 100%; + + transition: all .3s ease-in-out; + } + + .showHowToButton:hover { + background: #4a4a4a; + + transition: all .3s ease-in-out; + transform: scale(1.1); + } + + .howTo { + background: #292929; + + display: flex; + flex-direction: column; + + position: absolute; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + + max-width: 28rem; + padding: 1rem; + outline: .1rem solid #09cdda; + border-radius: .4rem; + } + + .howTo h1 { + padding-left: 2.5rem; + } + + .howTo ul li { + margin-bottom: .9rem; + } + + + #imageContainer { + display: none; + } + + + body { + background-color: #4a4a4a; + color: #fff; + + min-height: 100vh; + padding: 0; + margin: 0; + } + + .mainContent { + background-color: #3d3c3c; + position: relative; + + display: flex; + flex-direction: row; + /* gap: 1rem; */ + + width: max-content; + margin-inline: auto; + } + + .mainContent>div { + border: .1rem solid #ddd; + padding: 1rem; + + display: flex; + flex-direction: column; + justify-content: flex-start; + gap: 1rem; + } + + .selectImageContainer { + flex: 5; + + display: flex; + align-items: center; + + height: 100%; + padding: 20; + border: 0; + outline: var(--border-width) solid #ddd; + padding-right: 1rem; + } + + .previewImageContainer { + position: relative; + overflow: hidden; + } + + .previewImage { + background: #4a4a4a; + + cursor: pointer; + + height: 17rem; + width: 17rem; + border-radius: 100%; + } + + .selectImageText { + font-size: 1.5rem; + + display: flex; + flex-direction: row; + justify-content: center; + align-items: center; + + cursor: pointer; + } + + .selectImageText>img { + height: 2rem; + + transition: all .3s ease-in-out; + } + + .fileName { + max-width: 15ch; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + } + + .selectImageText:hover >img { + background-color: #2f83bc; + border-radius: 100%; + + transform: rotate(360deg); + } + + + + .option { + display: flex; + flex-direction: row; + justify-content: space-between; + align-items: center; + + text-wrap: nowrap; + } + + .pinColorPicker { + background-color: var(--printBackgroundColor); + background-color: red; + display: flex; + flex-direction: row; + + width: max-content; + padding: .15rem; + } + + .pinColorText { + background: var(--printBackgroundColor); + cursor: pointer; + + padding: .4rem; + border-radius: .4rem; + margin: 0; + } + + .pinColorHex { + background: none; + + width: 6ch; + border: none; + outline: none; + margin: 0; + } + + .pinColor { + border: none !important; + outline: none; + z-index: -100; + } + + + #generateTemplateButton { + background-color: #3498db; + color: #fff; + + font-family: "Kode Mono"; + font-size: 1.3rem; + font-weight: bold; + cursor: pointer; + + padding: 10px; + border: .1rem solid #ddd; + margin-top: auto; + + transition: all .1s ease-in-out; + } + + #generateTemplateButton:active { + background-color: rgb(61, 50, 222); + transition: all .1s ease-in-out; + } + + #imageNotSquareWarning { + background-color: rgb(137, 10, 10); + + display: flex; + flex-direction: row; + align-items: center; + justify-content: center; + gap: .5rem; + + position: absolute; + top: -3rem; + right: 0; + + box-sizing: border-box; + padding: .5rem; + width: 100%; + + opacity: 1; + transition: top .5s ease-in-out; + } + + #imageNotSquareWarning p { + margin: 0; + } + + + footer { + font-size: 1rem; + text-align: center; + font-family: copperplate, sans-serif; + + position: absolute; + bottom: 0; + + width: 100vw; + height: 3rem; + } + + footer img { + height: 1rem; + width: auto; + vertical-align: middle; + } + + footer a { + color: aqua; + text-decoration: none; + } +} diff --git a/css/style.css b/css/style.css index 5a6a4d5..b9fb34e 100644 --- a/css/style.css +++ b/css/style.css @@ -1,7 +1,13 @@ +@import url('https://fonts.googleapis.com/css2?family=Protest+Guerrilla&display=swap'); +@import url('https://fonts.googleapis.com/css2?family=Kode+Mono:wght@400..700&display=swap'); + + + :root { - --border-width: 1px; - --pinImage-size: 32mm; - --background-color-print: blue; /* Default background color for printing */ + --pinSize: 46mm; /* There entire diameter of the pin. Including the image and the outer margin */ + --pinImageSize: 32mm; /* The inner diameter of the pin, where the image is */ + --pinSpacing: 3mm; /* The space between the pins */ + --printBackgroundColor: none; } @@ -18,9 +24,18 @@ body { display: none !important; } +.disabled { + pointer-events: none; + opacity: .5; +} + +.noShow { + width: 0; + height: 0; +} + .shadowbox { background: #00000078; - /* background: green; */ display: flex; align-items: center; @@ -36,262 +51,4 @@ body { z-index: 1000; } -@media only screen { - .showHowToButton { - background: #292929; - - cursor: pointer; - - display: flex; - align-items: center; - justify-content: center; - - position: absolute; - top: 1rem; - right: 1rem; - - width: 3rem; - height: 3rem; - outline: .1rem solid #09cdda; - border-radius: 100%; - - transition: all .3s ease-in-out; - } - - .showHowToButton:hover { - background: #4a4a4a; - - transition: all .3s ease-in-out; - transform: scale(1.1); - } - - .howTo { - background: #292929; - - display: flex; - flex-direction: column; - - position: absolute; - top: 50%; - left: 50%; - transform: translate(-50%, -50%); - - max-width: 28rem; - padding: 1rem; - outline: .1rem solid #09cdda; - border-radius: .4rem; - } - - .howTo h1 { - padding-left: 2.5rem; - } - - .howTo ul li { - margin-bottom: .9rem; - } - - - #imageContainer { - display: none; - } - - - body { - background-color: #4a4a4a; - color: #fff; - - height: 100vh; - padding: 0; - margin: 0; - } - - #inputDiv { - background-color: #3d3c3c; - position: relative; - - width: 25rem; - border: var(--border-width) solid #ddd; - margin-inline: auto; - } - - #imageNotSquareWarning { - background-color: rgb(137, 10, 10); - - display: flex; - flex-direction: row; - align-items: center; - - position: absolute; - top: 0; - right: 0; - - padding: .5rem; - - opacity: 1; - transition: opacity .1s ease-in-out; /* Adjust the duration and easing as needed */ - } - - #imageNotSquareWarning.hidden { - opacity: 0; - pointer-events: none; /* Optionally disable pointer events when hidden */ - } - - #imageNotSquareWarning p { - margin: 0; - margin-right: .4rem; - } - - #previewImageContainer { - text-align: center; - height: 19rem; - width: calc(100%-2*var(--border-width)); - padding: 1rem; - - } - - #previewImage { - background: #4a4a4a; - - cursor: pointer; - - height: 17rem; - width: 17rem; - border-radius: 100%; - } - - #controlDiv { - display: flex; - justify-content: center; - align-items: center; - - height: 3rem; - - } - - .selectImageContainer { - flex: 5; - - display: flex; - align-items: center; - - height: 100%; - padding: 20; - border: 0; - outline: var(--border-width) solid #ddd; - padding-right: 1rem; - } - - body .selectImageContainer * { - cursor: pointer; - } - - #selectImageButton { - background: #585858; - - cursor: pointer; - - height: 100%; - margin-right: .7rem; - - transition: all .3s ease-in-out; - } - - #selectImageButton:hover { - background-color: #2f83bc; - border-radius: 100%; - - transition: all .3s ease-in-out; - transform: rotate(360deg); - } - - .fileName { - cursor: default; - } - - #generateTemplateButton { - flex: 2; - - background-color: #3498db; - color: #fff; - cursor: pointer; - - height: 100%; - /* min-width: 7rem; */ - padding: 10px; - border: 0; - outline: var(--border-width) solid #ddd; - - transition: all .1s ease-in-out; - } - - #generateTemplateButton:active { - background-color: rgb(61, 50, 222); - transition: all .1s ease-in-out; - } - - - - footer { - /* background-color: purple; */ - font-size: 1rem; - text-align: center; - font-family: copperplate, sans-serif; - - position: absolute; - bottom: 0; - - width: 100vw; - height: 3rem; - - } - - footer img { - height: 1rem; - width: auto; - vertical-align: middle; - } - - footer a { - color: aqua; - text-decoration: none; - } -} - - -/* STYLE FOR THE PIN GRID */ - -@media print { - body { - background-color: var(--background-color-print); /* Use the CSS variable for printing */ - } - #inputDiv, footer, .howToShadowbox, .showHowToButton { - display: none; - } - - .image-container { - display: flex; - flex-direction: column; - justify-content: space-between; - align-items: left; - margin-top: 20px; - - } - - .imgRow { - width: min-content; - height: min-content; - display: block; - } - - .pinImage { - /* border: .5mm solid #ca1616; */ - border: .5mm solid #000; - - width: var(--pinImage-size); - height: var(--pinImage-size); - padding: 5.5mm; - border-radius: 50%; - margin: 1.5mm; - } -} diff --git a/index.html b/index.html index 29b6fce..1cbd8b3 100644 --- a/index.html +++ b/index.html @@ -1,6 +1,10 @@ + pins + + + @@ -10,16 +14,16 @@ - pins - + + + -
@@ -37,32 +41,51 @@

HowTo pins

-
- +
+
+
+ +

Image is not square

+
+ + Image preview of pin image -
- Image preview of pin image +
+ Upload image + +
+ +
-
-
- +
+

Options

+ +
+ + +
+ +
+ + +
+ +
+ +

#000000

- upload image - No file chosen
+ +
-