-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[add] Image, Ratio, Scroll Boundary & Tooltip components
[optimize] update Upstream packages [remove] useless Component files
- Loading branch information
Showing
10 changed files
with
220 additions
and
164 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "boot-cell", | ||
"version": "2.0.0-beta.2", | ||
"version": "2.0.0-beta.3", | ||
"license": "LGPL-3.0", | ||
"author": "[email protected]", | ||
"description": "Web Components UI library based on WebCell v3, BootStrap v5, BootStrap Icon v1 & FontAwesome v6", | ||
|
@@ -26,10 +26,10 @@ | |
"dependencies": { | ||
"@swc/helpers": "^0.5.3", | ||
"classnames": "^2.5.1", | ||
"dom-renderer": "^2.0.5", | ||
"dom-renderer": "^2.0.6", | ||
"mobx": "^6.12.0", | ||
"regenerator-runtime": "^0.14.1", | ||
"web-cell": "^3.0.0-rc.6", | ||
"web-cell": "^3.0.0-rc.7", | ||
"web-utility": "^4.1.3" | ||
}, | ||
"peerDependencies": { | ||
|
@@ -49,7 +49,7 @@ | |
"@parcel/transformer-less": "~2.11.0", | ||
"@parcel/transformer-typescript-tsc": "^2.11.0", | ||
"@parcel/transformer-typescript-types": "~2.11.0", | ||
"@peculiar/webcrypto": "^1.4.3", | ||
"@peculiar/webcrypto": "^1.4.4", | ||
"@tech_query/snabbdom-looks-like": "^2.0.1", | ||
"@types/classnames": "^2.3.1", | ||
"@types/jest": "^29.5.11", | ||
|
@@ -66,11 +66,11 @@ | |
"markdown-area-element": "^0.2.3", | ||
"open-cli": "^8.0.0", | ||
"parcel": "~2.11.0", | ||
"prettier": "^3.1.1", | ||
"prettier": "^3.2.4", | ||
"ts-jest": "^29.1.1", | ||
"ts-node": "^10.9.2", | ||
"typedoc": "^0.25.7", | ||
"typedoc-plugin-mdn-links": "^3.1.11", | ||
"typedoc-plugin-mdn-links": "^3.1.12", | ||
"typescript": "~5.3.3" | ||
}, | ||
"scripts": { | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import classNames from 'classnames'; | ||
import { FC, WebCellProps } from 'web-cell'; | ||
|
||
export type ImageProps = WebCellProps<HTMLImageElement> & | ||
Partial< | ||
Record<'fluid' | 'rounded' | 'roundedCircle' | 'thumbnail', boolean> | ||
>; | ||
|
||
export const Image: FC<ImageProps> = ({ | ||
className, | ||
fluid, | ||
rounded, | ||
roundedCircle, | ||
thumbnail, | ||
...props | ||
}) => ( | ||
<img | ||
className={classNames( | ||
fluid && 'img-fluid', | ||
thumbnail && `img-thumbnail`, | ||
{ rounded }, | ||
roundedCircle && 'rounded-circle', | ||
className | ||
)} | ||
{...props} | ||
/> | ||
); |
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import classNames from 'classnames'; | ||
import { FC, WebCellProps } from 'web-cell'; | ||
|
||
export interface RatioProps extends WebCellProps { | ||
aspectRatio?: number | '1x1' | '4x3' | '16x9' | '21x9'; | ||
} | ||
|
||
export const Ratio: FC<RatioProps> = ({ aspectRatio = '1x1', children }) => ( | ||
<div | ||
className={classNames( | ||
'ratio', | ||
typeof aspectRatio === 'string' && `ratio-${aspectRatio}` | ||
)} | ||
style={ | ||
typeof aspectRatio === 'number' | ||
? { '--bs-aspect-ratio': `${aspectRatio * 100}%` } | ||
: undefined | ||
} | ||
> | ||
{children} | ||
</div> | ||
); |
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,61 @@ | ||
import classNames from 'classnames'; | ||
import { JsxChildren } from 'dom-renderer'; | ||
import { FC, WebCellProps } from 'web-cell'; | ||
|
||
export type EdgePosition = 'top' | 'bottom' | 'left' | 'right'; | ||
|
||
export type TouchHandler = (edge: EdgePosition) => any; | ||
|
||
export interface ScrollBoundaryProps | ||
extends WebCellProps, | ||
Partial<Record<EdgePosition, JsxChildren>> { | ||
onTouch: TouchHandler; | ||
} | ||
|
||
function touch(edge: EdgePosition, onTouch: TouchHandler) { | ||
return (node: HTMLElement | null) => | ||
node && | ||
new IntersectionObserver( | ||
([{ isIntersecting }]) => isIntersecting && onTouch(edge) | ||
).observe(node); | ||
} | ||
|
||
export const ScrollBoundary: FC<ScrollBoundaryProps> = ({ | ||
className, | ||
onTouch, | ||
top, | ||
left, | ||
right, | ||
bottom, | ||
children | ||
}) => ( | ||
<div className={classNames('position-relative', className)}> | ||
<div | ||
className="position-absolute top-0 left-0 w-100" | ||
ref={touch('top', onTouch)} | ||
> | ||
{top} | ||
</div> | ||
<div | ||
className="position-absolute top-0 left-0 h-100" | ||
ref={touch('left', onTouch)} | ||
> | ||
{left} | ||
</div> | ||
|
||
{children} | ||
|
||
<div | ||
className="position-absolute top-0 right-0 h-100" | ||
ref={touch('right', onTouch)} | ||
> | ||
{right} | ||
</div> | ||
<div | ||
className="position-absolute top-100 left-0 w-100" | ||
ref={touch('bottom', onTouch)} | ||
> | ||
{bottom} | ||
</div> | ||
</div> | ||
); |
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,76 @@ | ||
import { JsxChildren } from 'dom-renderer'; | ||
import { observable } from 'mobx'; | ||
import { | ||
FC, | ||
WebCell, | ||
WebCellProps, | ||
attribute, | ||
component, | ||
observer | ||
} from 'web-cell'; | ||
|
||
export const Tooltip: FC<WebCellProps> = ({ | ||
className = '', | ||
children, | ||
...props | ||
}) => ( | ||
<div | ||
className={`tooltip bs-tooltip show position-absolute ${className}`} | ||
role="tooltip" | ||
{...props} | ||
> | ||
<div className="tooltip-arrow" /> | ||
<div className="tooltip-inner">{children}</div> | ||
</div> | ||
); | ||
|
||
export interface TooltipBoxProps extends WebCellProps { | ||
content: JsxChildren; | ||
} | ||
|
||
export interface TooltipBox extends WebCell {} | ||
|
||
@component({ | ||
tagName: 'tooltip-box', | ||
mode: 'open' | ||
}) | ||
@observer | ||
export class TooltipBox extends HTMLElement implements WebCell { | ||
declare props: TooltipBoxProps; | ||
|
||
content: JsxChildren; | ||
|
||
@attribute | ||
@observable | ||
accessor show = false; | ||
|
||
connectedCallback() { | ||
this.style.display = 'inline-block'; | ||
|
||
this.addEventListener('mouseenter', this.handleToggle); | ||
this.addEventListener('mouseleave', this.handleToggle); | ||
} | ||
|
||
disconnectedCallback() { | ||
this.removeEventListener('mouseenter', this.handleToggle); | ||
this.removeEventListener('mouseleave', this.handleToggle); | ||
} | ||
|
||
handleToggle = () => (this.show = !this.show); | ||
|
||
render() { | ||
const { content, show } = this; | ||
|
||
return ( | ||
<> | ||
<link | ||
rel="stylesheet" | ||
href="https://unpkg.com/[email protected]/dist/css/bootstrap.min.css" | ||
/> | ||
<slot /> | ||
|
||
{show && <Tooltip>{content}</Tooltip>} | ||
</> | ||
); | ||
} | ||
} |
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
Oops, something went wrong.