-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
38 changed files
with
259 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -243,6 +243,10 @@ h2 { | |
font-weight: 600; | ||
} | ||
|
||
h2:not(:first-child) { | ||
margin-top: 2rem; | ||
} | ||
|
||
h3 { | ||
font-size: 1.2em; | ||
} | ||
|
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
## Lightbox Props | ||
|
||
Supports all PhotoSwipe properties [https://photoswipe.com/options/](https://photoswipe.com/options/) | ||
|
||
## Lightbox 属性 | ||
|
||
支持所有 PhotoSwipe 的属性 [https://photoswipe.com/options/](https://photoswipe.com/options/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import content from './api.md?raw' | ||
import { tag, Component } from 'omi' | ||
import '../../common/markdown-renderer' | ||
|
||
@tag('lightbox-api') | ||
export class API extends Component { | ||
render() { | ||
return <markdown-renderer content={content}></markdown-renderer> | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { tag, Component, classNames } from 'omi' | ||
import { tailwind } from '@/tailwind' | ||
|
||
import PhotoSwipeLightbox from 'photoswipe/lightbox' | ||
// 插入到 head | ||
import 'photoswipe/style.css' | ||
|
||
@tag('o-lightbox') | ||
export class Button extends Component { | ||
static css = [ | ||
tailwind, | ||
`:host { | ||
display: block; | ||
}`, | ||
] | ||
|
||
static defaultProps = { | ||
className: '', | ||
} | ||
|
||
installed() { | ||
const slot = this.shadowRoot.querySelector('slot') | ||
|
||
const gallery = slot.assignedNodes()[0] | ||
|
||
// todo 按需加载? | ||
// 加载所有 a 标签的 href 属性作为 img 的 src,然后获取 img 的 width 和 height 属性设置到 a 标签的 data-pswp-width 和 data-pswp-height | ||
const anchors = gallery.querySelectorAll('a') | ||
anchors.forEach((anchor) => { | ||
const imgSrc = anchor.getAttribute('href') | ||
const img = new Image() | ||
img.src = imgSrc | ||
img.onload = () => { | ||
const width = img.width | ||
const height = img.height | ||
anchor.setAttribute('data-pswp-width', width) | ||
anchor.setAttribute('data-pswp-height', height) | ||
} | ||
}) | ||
|
||
const { children, ...options } = this.props | ||
// dom 会插入到 body,而不是 shadowRoot 内 | ||
const lightbox = new PhotoSwipeLightbox({ | ||
gallery: gallery, | ||
children: 'a', | ||
...options, | ||
pswpModule: () => import('photoswipe'), | ||
}) | ||
lightbox.init() | ||
} | ||
|
||
render(props) { | ||
return <slot></slot> | ||
} | ||
} | ||
|
||
window.Omiu = window.Omiu || {} | ||
|
||
class Lightbox { | ||
constructor(options) { | ||
this.lightbox = new PhotoSwipeLightbox({ | ||
...options, | ||
pswpModule: () => import('photoswipe'), | ||
}) | ||
lightbox.init() | ||
} | ||
} | ||
|
||
Omiu.Lightbox = Lightbox |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
import '@/site/code-showcase' | ||
|
||
import { tag, Component } from 'omi' | ||
import { tailwind } from '@/tailwind' | ||
|
||
import './index' | ||
|
||
@tag('lightbox-page') | ||
export class ButtonPage extends Component { | ||
static css = [ | ||
tailwind, | ||
` | ||
o-button{ margin: 0.2em; } | ||
code-showcase{ margin-bottom: 2em; } | ||
`, | ||
] | ||
|
||
render() { | ||
return ( | ||
<div className="container my-12 !max-w-full mb-48"> | ||
{/* <!-- Section: Basic example --> */} | ||
<section> | ||
{/* <!-- Title --> */} | ||
<h2 className="mb-5 mt-0 text-3xl font-semibold leading-normal" id="basic_example" data-te-spy-item> | ||
Basic example | ||
</h2> | ||
{/* <!-- Description --> */} | ||
<p className="mb-3"> | ||
An alert displays a short, important message in a way that attracts the user's attention without | ||
interrupting the user's task. | ||
</p> | ||
|
||
<code-showcase | ||
code={`<o-lightbox> | ||
<div class="flex flex-col space-y-5 lg:flex-row lg:space-x-5 lg:space-y-0"> | ||
<div class="flex h-full w-full flex-1 flex-col"> | ||
<a | ||
href="https://mdbcdn.b-cdn.net/img/Photos/Slides/1.webp" | ||
target="_blank" | ||
> | ||
<img | ||
src="https://mdbcdn.b-cdn.net/img/Photos/Thumbnails/Slides/1.webp" | ||
alt="Table Full of Spices" | ||
class="mb-5 w-full cursor-zoom-in data-[te-lightbox-disabled]:cursor-auto" | ||
/> | ||
</a> | ||
<a | ||
href="https://mdbcdn.b-cdn.net/img/Photos/Square/1.webp" | ||
target="_blank" | ||
> | ||
<img | ||
src="https://mdbcdn.b-cdn.net/img/Photos/Thumbnails/Square/1.webp" | ||
alt="Coconut with Strawberries" | ||
class="w-full cursor-zoom-in data-[te-lightbox-disabled]:cursor-auto" | ||
/> | ||
</a> | ||
</div> | ||
<div class="flex h-full w-full flex-1 flex-col"> | ||
<a | ||
href="https://mdbcdn.b-cdn.net/img/Photos/Vertical/1.webp" | ||
target="_blank" | ||
> | ||
<img | ||
src="https://mdbcdn.b-cdn.net/img/Photos/Thumbnails/Vertical/1.webp" | ||
alt="Dark Roast Iced Coffee" | ||
class="w-full cursor-zoom-in data-[te-lightbox-disabled]:cursor-auto" | ||
/> | ||
</a> | ||
</div> | ||
</div> | ||
</o-lightbox>`} | ||
> | ||
<o-lightbox> | ||
<div class="flex flex-col space-y-5 lg:flex-row lg:space-x-5 lg:space-y-0"> | ||
<div class="flex h-full w-full flex-1 flex-col"> | ||
<a href="https://mdbcdn.b-cdn.net/img/Photos/Slides/1.webp" target="_blank"> | ||
<img | ||
src="https://mdbcdn.b-cdn.net/img/Photos/Thumbnails/Slides/1.webp" | ||
alt="Table Full of Spices" | ||
class="mb-5 w-full cursor-zoom-in data-[te-lightbox-disabled]:cursor-auto" | ||
/> | ||
</a> | ||
|
||
<a href="https://mdbcdn.b-cdn.net/img/Photos/Square/1.webp" target="_blank"> | ||
<img | ||
src="https://mdbcdn.b-cdn.net/img/Photos/Thumbnails/Square/1.webp" | ||
alt="Coconut with Strawberries" | ||
class="w-full cursor-zoom-in data-[te-lightbox-disabled]:cursor-auto" | ||
/> | ||
</a> | ||
</div> | ||
<div class="flex h-full w-full flex-1 flex-col"> | ||
<a href="https://mdbcdn.b-cdn.net/img/Photos/Vertical/1.webp" target="_blank"> | ||
<img | ||
src="https://mdbcdn.b-cdn.net/img/Photos/Thumbnails/Vertical/1.webp" | ||
alt="Dark Roast Iced Coffee" | ||
class="w-full cursor-zoom-in data-[te-lightbox-disabled]:cursor-auto" | ||
/> | ||
</a> | ||
</div> | ||
</div> | ||
</o-lightbox> | ||
</code-showcase> | ||
</section> | ||
</div> | ||
) | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters