Skip to content
This repository was archived by the owner on Aug 7, 2023. It is now read-only.

Commit 7e2cc6b

Browse files
committed
zoomable image works as a modal now :)
1 parent 0452946 commit 7e2cc6b

File tree

4 files changed

+93
-27
lines changed

4 files changed

+93
-27
lines changed

src/components.d.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,9 @@ export namespace Components {
174174
'listenFor': string;
175175
}
176176
interface DocsZoomableImage {
177-
'alt': string;
177+
'close': () => Promise<void>;
178178
'href': string;
179+
'open': () => Promise<void>;
179180
}
180181
interface FileTree {}
181182
interface FileTreeDirectory {
@@ -640,7 +641,6 @@ declare namespace LocalJSX {
640641
'listenFor'?: string;
641642
}
642643
interface DocsZoomableImage {
643-
'alt'?: string;
644644
'href'?: string;
645645
}
646646
interface FileTree {}
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,67 @@
1-
.Zoom-Image-Container {
2-
transition: transform .2s; /* Animation */
3-
padding: 10px;
4-
z-index: 90000;
5-
overflow: visible;
6-
position: relative;
7-
}
8-
.Zoom-Image-Container img {
9-
width: 100%;
10-
transition: transform 0.25s ease;
11-
cursor: zoom-in;
12-
background-color: white;
1+
/* Style the Image Used to Trigger the Modal */
2+
.notModalImg {
3+
border-radius: 5px;
4+
cursor: pointer;
5+
transition: 0.3s;
136
}
147

15-
.Zoom-Image-Container input[type=checkbox] {
8+
.notModalImg:hover {opacity: 0.7;}
9+
10+
/* The Modal (background) */
11+
.modal {
1612
display: none
1713
}
1814

19-
.Zoom-Image-Container input[type=checkbox]:checked~img {
20-
transform: scale(3);
21-
cursor: zoom-out;
15+
.openModal {
16+
display: block; /* Hidden by default */
17+
position: fixed; /* Stay in place */
18+
z-index: 1; /* Sit on top */
19+
padding-top: 100px; /* Location of the box */
20+
left: 0;
21+
top: 0;
22+
width: 100%; /* Full width */
23+
height: 100%; /* Full height */
24+
overflow: auto; /* Enable scroll if needed */
25+
background-color: rgb(0,0,0); /* Fallback color */
26+
background-color: rgba(0,0,0,0.8); /* Black w/ opacity */
27+
}
28+
29+
.modalImg {
30+
margin: auto;
31+
display: block;
32+
width: 90%;
33+
animation-name: zoom;
34+
animation-duration: 0.6s;
2235
background-color: white;
36+
padding: 10px;
37+
}
38+
39+
@keyframes zoom {
40+
from {transform:scale(0)}
41+
to {transform:scale(1)}
42+
}
43+
44+
/* The Close Button */
45+
.close {
46+
position: absolute;
47+
top: 40px;
48+
right: 35px;
49+
color: #f1f1f1;
50+
font-size: 40px;
51+
font-weight: bold;
52+
transition: 0.3s;
53+
}
54+
55+
.close:hover,
56+
.close:focus {
57+
color: #bbb;
58+
text-decoration: none;
59+
cursor: pointer;
60+
}
61+
62+
/* 100% Image Width on Smaller Screens */
63+
@media only screen and (max-width: 700px){
64+
.modalImg {
65+
width: 100%;
66+
}
2367
}

src/components/zoomable-image/zoomable-image.tsx

+30-8
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,43 @@
1-
import { Component, Prop, h } from '@stencil/core';
1+
import { Component, Element, Prop, h, State, Listen, Method } from '@stencil/core';
22

33
@Component({
44
tag: 'docs-zoomable-image',
55
styleUrl: 'zoomable-image.css'
66
})
77
export class ZoomableImage {
8-
@Prop() href: string;
9-
@Prop() alt: string;
8+
@Prop() href: string
9+
@State() isOpen = false
10+
@Element() element: HTMLElement;
11+
@Listen('click', { target: 'window' })
12+
13+
handleClick(event: MouseEvent) {
14+
const isNode = event.target instanceof Node;
15+
const isOurs = isNode && this.element.contains(event.target as Node);
16+
17+
if (!isOurs) {
18+
this.close();
19+
}
20+
}
21+
22+
@Method()
23+
async close() {
24+
this.isOpen = false;
25+
}
26+
27+
@Method()
28+
async open() {
29+
this.isOpen = true
30+
}
1031

1132
render() {
1233

1334
return (
14-
<div class="Zoom-Image-Container">
15-
<label>
16-
<input type="checkbox" />
17-
<img src={this.href} alt={this.alt} />
18-
</label>
35+
<div>
36+
<img onClick={this.open.bind(this)} class="notModalImg" src={this.href} alt="Integrando sua Startup" />
37+
<div class={ this.isOpen ? "openModal" : "modal" }>
38+
<span onClick={this.close.bind(this)} class="close">&times;</span>
39+
<img class="modalImg" src={this.href} />
40+
</div>
1941
</div>
2042
);
2143
}

src/pages/forstartups.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ A Layers oferece aos desenvolvedores uma série de funcionalidades para que crie
3434

3535
## Etapas do Processo de Integração
3636

37-
<docs-zoomable-image href="https://cdn.layers.digital/demo-developers/uploads/a2ce8aea-fed6-4ce8-b525-5da9d2fadfe5/Fluxo-Startups-Bonitinho.png" alt="Fluxo de Integração com Startups"></docs-zoomable-image>
37+
<docs-zoomable-image href="https://cdn.layers.digital/demo-developers/uploads/a2ce8aea-fed6-4ce8-b525-5da9d2fadfe5/Fluxo-Startups-Bonitinho.png"></docs-zoomable-image>
3838

3939
O processo de integração consiste em 5 etapas:
4040
- Primeiro contato: Layers e Startup se conhecem e interagem com o objetivo de verificar se faz sentido para os dois uma integração.

0 commit comments

Comments
 (0)