Skip to content

Commit e9c5620

Browse files
committed
[add] Row & Col components
[refactor] rewrite Alert & BreadCrumb components to WebCell v3 [optimize] Class updating of Nav component [fix] Pagination margin bugs [optimize] update Upstream packages
1 parent 0b9110f commit e9c5620

File tree

9 files changed

+278
-166
lines changed

9 files changed

+278
-166
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "boot-cell",
3-
"version": "2.0.0-rc.1",
3+
"version": "2.0.0-rc.2",
44
"license": "LGPL-3.0",
55
"author": "[email protected]",
66
"description": "Web Components UI library based on WebCell v3, BootStrap v5, BootStrap Icon v1 & FontAwesome v6",
@@ -31,7 +31,7 @@
3131
"mobx": "^6.13.6",
3232
"regenerator-runtime": "^0.14.1",
3333
"web-cell": "^3.0.3",
34-
"web-utility": "^4.4.2"
34+
"web-utility": "^4.4.3"
3535
},
3636
"peerDependencies": {
3737
"@fortawesome/fontawesome-free": "^6",

pnpm-lock.yaml

Lines changed: 72 additions & 72 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

source/Layout/Grid.tsx

Lines changed: 77 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { JsxProps } from 'dom-renderer';
2-
import { FC } from 'web-cell';
1+
import classNames from 'classnames';
2+
import { FC, WebCellProps } from 'web-cell';
33

44
import { Size } from '../type';
55

6-
export interface ContainerProps extends JsxProps<HTMLDivElement> {
6+
export interface ContainerProps extends WebCellProps {
77
fluid?: boolean | Size;
88
}
99

@@ -22,3 +22,77 @@ export const Container: FC<ContainerProps> = ({
2222
{children}
2323
</div>
2424
);
25+
26+
export type RowProps = Record<'xs' | Size, number | 'auto'> & WebCellProps;
27+
28+
export const Row: FC<RowProps> = ({
29+
className,
30+
xs,
31+
sm,
32+
md,
33+
lg,
34+
xl,
35+
xxl,
36+
children,
37+
...props
38+
}) => {
39+
const size = xs || sm || md || lg || xl || xxl;
40+
const columnClass = size
41+
? `row-cols${
42+
xs
43+
? ''
44+
: sm
45+
? '-sm'
46+
: md
47+
? '-md'
48+
: lg
49+
? '-lg'
50+
: xl
51+
? '-xl'
52+
: xxl && '-xxl'
53+
}-${size}`
54+
: '';
55+
56+
return (
57+
<div className={classNames('row', columnClass, className)} {...props}>
58+
{children}
59+
</div>
60+
);
61+
};
62+
63+
export type ColProps = RowProps;
64+
65+
export const Col: FC<ColProps> = ({
66+
className,
67+
xs,
68+
sm,
69+
md,
70+
lg,
71+
xl,
72+
xxl,
73+
children,
74+
...props
75+
}) => {
76+
const size = xs || sm || md || lg || xl || xxl;
77+
const columnClass = size
78+
? `col${
79+
xs
80+
? ''
81+
: sm
82+
? '-sm'
83+
: md
84+
? '-md'
85+
: lg
86+
? '-lg'
87+
: xl
88+
? '-xl'
89+
: xxl && '-xxl'
90+
}-${size}`
91+
: '';
92+
93+
return (
94+
<div className={classNames('col', columnClass, className)} {...props}>
95+
{children}
96+
</div>
97+
);
98+
};

source/Navigator/BreadCrumb.tsx

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import classNames from 'classnames';
2+
import { FC, WebCellProps } from 'web-cell';
3+
4+
export type BreadcrumbProps = WebCellProps;
5+
6+
export const BreadCrumb: FC<BreadcrumbProps> = ({ children, ...props }) => (
7+
<nav {...props}>
8+
<ol className="breadcrumb">{children}</ol>
9+
</nav>
10+
);
11+
12+
export interface BreadcrumbItemProps extends WebCellProps<HTMLAnchorElement> {
13+
active?: boolean;
14+
}
15+
16+
export const BreadcrumbItem: FC<BreadcrumbItemProps> = ({
17+
className = '',
18+
href,
19+
target,
20+
active,
21+
children,
22+
...props
23+
}) => (
24+
<li
25+
className={classNames('breadcrumb-item', { active }, className)}
26+
ariaCurrent={active ? 'page' : undefined}
27+
{...props}
28+
>
29+
{active ? children : <a {...{ href, target }}>{children}</a>}
30+
</li>
31+
);

source/Navigator/Nav.tsx

Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
1+
import classNames from 'classnames';
12
import { JsxChildren } from 'dom-renderer';
2-
import { FC, WebCell, WebCellProps, component } from 'web-cell';
3+
import { observable } from 'mobx';
4+
import {
5+
FC,
6+
WebCell,
7+
WebCellProps,
8+
attribute,
9+
component,
10+
reaction
11+
} from 'web-cell';
12+
import { CustomElement } from 'web-utility';
313

414
import { ButtonProps } from '../Form/Button';
515
import { DropdownButton } from './Dropdown';
@@ -41,21 +51,47 @@ export const NavDropdown: FC<NavDropdownProps> = ({
4151
</DropdownButton>
4252
);
4353

44-
export interface Nav extends WebCell {}
54+
export interface NavProps extends WebCellProps {
55+
variant?: 'pills' | 'underline' | 'tabs';
56+
fill?: boolean;
57+
justify?: boolean;
58+
}
59+
60+
export interface Nav extends WebCell<NavProps> {}
4561

4662
@component({
4763
tagName: 'bs-nav',
4864
mode: 'open'
4965
})
50-
export class Nav extends HTMLElement {
51-
declare props: WebCellProps;
66+
export class Nav extends HTMLElement implements CustomElement {
67+
@attribute
68+
@observable
69+
accessor variant: 'pills' | 'underline' | 'tabs' | undefined;
70+
71+
@attribute
72+
@observable
73+
accessor fill = false;
74+
75+
@attribute
76+
@observable
77+
accessor justify = false;
78+
79+
@reaction(({ variant, fill, justify }) => ({ variant, fill, justify }))
80+
protected updateClass({ variant, fill, justify }: this) {
81+
this.className = classNames('nav', this.className, {
82+
[`nav-${variant}`]: variant,
83+
'nav-fill': fill,
84+
[`nav-justified`]: justify
85+
});
86+
}
5287

5388
connectedCallback() {
89+
this.role = 'tablist';
90+
5491
const navBar = this.closest<OffcanvasNavbar>(
5592
'offcanvas-navbar, .navbar'
5693
);
57-
58-
if (!navBar) return this.classList.add('nav');
94+
if (!navBar) return;
5995

6096
const expand =
6197
navBar.expand ||

source/Navigator/Pagination.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export const Pagination: FC<PaginationProps> = ({
1414
...props
1515
}) => (
1616
<nav {...props}>
17-
<ol className={`pagination ${size ? `pagination-${size}` : ''}`}>
17+
<ol className={`m-0 pagination ${size ? `pagination-${size}` : ''}`}>
1818
{children}
1919
</ol>
2020
</nav>
@@ -75,7 +75,7 @@ export const Pager: FC<PagerProps> = ({
7575

7676
return (
7777
<form
78-
className="d-flex align-items-center gap-3"
78+
className="m-0 d-flex align-items-center gap-3"
7979
onSubmit={onChange && (event => event.preventDefault())}
8080
>
8181
<FormControl
@@ -104,7 +104,7 @@ export const Pager: FC<PagerProps> = ({
104104
onChange?.({ pageSize, pageIndex: +input.value });
105105
}}
106106
/>
107-
<Pagination className="my-0">
107+
<Pagination>
108108
{pageIndex > 1 && (
109109
<PaginationItem {...propsOf(1)}>1</PaginationItem>
110110
)}

source/Prompt/Alert.tsx

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import classNames from 'classnames';
2+
import { FC, WebCellProps } from 'web-cell';
3+
4+
import { CloseButton } from '../Form/Button';
5+
import { TextColor } from '../type';
6+
7+
export interface AlertProps extends WebCellProps {
8+
variant?: TextColor;
9+
title?: string;
10+
dismissible?: boolean;
11+
show?: boolean;
12+
onClose?: (event: MouseEvent) => any;
13+
}
14+
15+
export const Alert: FC<AlertProps> = ({
16+
className,
17+
variant = 'primary',
18+
title,
19+
children,
20+
show = true,
21+
dismissible,
22+
onClose
23+
}) => (
24+
<aside
25+
className={classNames(
26+
'alert',
27+
`alert-${variant}`,
28+
{ 'alert-dismissible fade': dismissible, show },
29+
className
30+
)}
31+
role="alert"
32+
>
33+
{title && <h4 className="alert-heading">{title}</h4>}
34+
35+
{children}
36+
37+
{dismissible && <CloseButton onClick={onClose} />}
38+
</aside>
39+
);
40+
41+
export type AlertLinkProps = WebCellProps<HTMLAnchorElement>;
42+
43+
export const AlertLink: FC<AlertLinkProps> = ({
44+
className = '',
45+
children,
46+
...props
47+
}) => (
48+
<a className={`alert-link ${className}`} {...props}>
49+
{children}
50+
</a>
51+
);

v1/Navigator/BreadCrumb.tsx

Lines changed: 0 additions & 29 deletions
This file was deleted.

v1/Prompt/Alert.tsx

Lines changed: 0 additions & 51 deletions
This file was deleted.

0 commit comments

Comments
 (0)