@startupjs-ui/breadcrumbs 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/README.mdx +185 -0
- package/index.cssx.styl +53 -0
- package/index.d.ts +32 -0
- package/index.tsx +104 -0
- package/package.json +23 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
+
|
|
6
|
+
## [0.1.3](https://github.com/startupjs/startupjs-ui/compare/v0.1.2...v0.1.3) (2025-12-29)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @startupjs-ui/breadcrumbs
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [0.1.2](https://github.com/startupjs/startupjs-ui/compare/v0.1.1...v0.1.2) (2025-12-29)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Features
|
|
18
|
+
|
|
19
|
+
* add mdx and docs packages. Refactor docs to get rid of any @startupjs/ui usage and use startupjs-ui instead ([703c926](https://github.com/startupjs/startupjs-ui/commit/703c92636efb0421ffd11783f692fc892b74018f))
|
|
20
|
+
* **breadcrumbs:** refactor Breadcrumbs component ([233206d](https://github.com/startupjs/startupjs-ui/commit/233206da7306cf8cc0e61e3f55717f326d5ee57c))
|
package/README.mdx
ADDED
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import Breadcrumbs, { _PropsJsonSchema as BreadcrumbsPropsJsonSchema } from './index'
|
|
2
|
+
import Br from '@startupjs-ui/br'
|
|
3
|
+
import Div from '@startupjs-ui/div'
|
|
4
|
+
import { faAnchor, faBook, faGift, faHome, faRocket } from '@fortawesome/free-solid-svg-icons'
|
|
5
|
+
import { Sandbox } from '@startupjs-ui/docs'
|
|
6
|
+
|
|
7
|
+
# Breadcrumbs
|
|
8
|
+
Breadcrumbs indicate the current page’s location within a navigational hierarchy and allow users to navigate through the hierarchy.
|
|
9
|
+
|
|
10
|
+
```jsx
|
|
11
|
+
import { Breadcrumbs } from 'startupjs-ui'
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Simple example
|
|
15
|
+
|
|
16
|
+
```jsx example
|
|
17
|
+
return (
|
|
18
|
+
<Breadcrumbs
|
|
19
|
+
routes={[
|
|
20
|
+
{
|
|
21
|
+
to: '#startupjs',
|
|
22
|
+
name: 'StartupJs'
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
to: '#docs',
|
|
26
|
+
name: 'Docs'
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
to: '#component',
|
|
30
|
+
name: 'Component'
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
to: '#Breadcrumbs',
|
|
34
|
+
name: 'Breadcrumbs'
|
|
35
|
+
}
|
|
36
|
+
]}
|
|
37
|
+
/>
|
|
38
|
+
)
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Custom Separator
|
|
42
|
+
|
|
43
|
+
Separator is `/` by default. It can be changed by passing string to `separator` prop.
|
|
44
|
+
|
|
45
|
+
```jsx example
|
|
46
|
+
return (
|
|
47
|
+
<Breadcrumbs
|
|
48
|
+
separator='>'
|
|
49
|
+
routes={[
|
|
50
|
+
{
|
|
51
|
+
to: '#startupjs',
|
|
52
|
+
name: 'StartupJs'
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
to: '#docs',
|
|
56
|
+
name: 'Docs'
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
to: '#component',
|
|
60
|
+
name: 'Component'
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
to: '#Breadcrumbs',
|
|
64
|
+
name: 'Breadcrumbs'
|
|
65
|
+
}
|
|
66
|
+
]}
|
|
67
|
+
/>
|
|
68
|
+
)
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Icons
|
|
72
|
+
|
|
73
|
+
Each route object accepts its own icon in `icon` property. Position of icon can be changed by passing `iconPosition` to component (`left` by default).
|
|
74
|
+
|
|
75
|
+
```jsx example
|
|
76
|
+
return (
|
|
77
|
+
<Breadcrumbs
|
|
78
|
+
separator='>'
|
|
79
|
+
routes={[
|
|
80
|
+
{
|
|
81
|
+
to: '#startupjs',
|
|
82
|
+
name: 'StartupJs',
|
|
83
|
+
icon: faRocket
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
to: '#docs',
|
|
87
|
+
name: 'Docs',
|
|
88
|
+
icon: faBook
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
to: '#component',
|
|
92
|
+
name: 'Component',
|
|
93
|
+
icon: faGift
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
to: '#Breadcrumbs',
|
|
97
|
+
name: 'Breadcrumbs',
|
|
98
|
+
icon: faAnchor
|
|
99
|
+
}
|
|
100
|
+
]}
|
|
101
|
+
/>
|
|
102
|
+
)
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## Sizes
|
|
106
|
+
|
|
107
|
+
Size is `m` by default. It can be changed by changing `size` prop. Possible values of property can be found in the `Sandbox` section at the bottom of the page.
|
|
108
|
+
|
|
109
|
+
```jsx example
|
|
110
|
+
return (
|
|
111
|
+
<Div>
|
|
112
|
+
<Breadcrumbs
|
|
113
|
+
size='l'
|
|
114
|
+
routes={[
|
|
115
|
+
{
|
|
116
|
+
to: '#startupjs',
|
|
117
|
+
name: 'StartupJs'
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
to: '#docs',
|
|
121
|
+
name: 'Docs'
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
to: '#component',
|
|
125
|
+
name: 'Component'
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
to: '#Breadcrumbs',
|
|
129
|
+
name: 'Breadcrumbs'
|
|
130
|
+
}
|
|
131
|
+
]}
|
|
132
|
+
/>
|
|
133
|
+
<Br />
|
|
134
|
+
<Breadcrumbs
|
|
135
|
+
size='s'
|
|
136
|
+
routes={[
|
|
137
|
+
{
|
|
138
|
+
to: '#startupjs',
|
|
139
|
+
name: 'StartupJs'
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
to: '#docs',
|
|
143
|
+
name: 'Docs'
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
to: '#component',
|
|
147
|
+
name: 'Component'
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
to: '#Breadcrumbs',
|
|
151
|
+
name: 'Breadcrumbs'
|
|
152
|
+
}
|
|
153
|
+
]}
|
|
154
|
+
/>
|
|
155
|
+
</Div>
|
|
156
|
+
)
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
## Sandbox
|
|
160
|
+
|
|
161
|
+
<Sandbox
|
|
162
|
+
Component={Breadcrumbs}
|
|
163
|
+
propsJsonSchema={BreadcrumbsPropsJsonSchema}
|
|
164
|
+
props={{
|
|
165
|
+
routes: [
|
|
166
|
+
{
|
|
167
|
+
icon: faHome,
|
|
168
|
+
to: '#',
|
|
169
|
+
name: 'Home'
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
to: '#',
|
|
173
|
+
name: 'Section'
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
to: '#',
|
|
177
|
+
name: 'Page'
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
to: '#sandbox',
|
|
181
|
+
name: 'Sandbox'
|
|
182
|
+
}
|
|
183
|
+
]
|
|
184
|
+
}}
|
|
185
|
+
/>
|
package/index.cssx.styl
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
_iconMargin = 0.5u
|
|
2
|
+
|
|
3
|
+
.iconWrapper
|
|
4
|
+
&.left
|
|
5
|
+
&.xs
|
|
6
|
+
&.s
|
|
7
|
+
&.m
|
|
8
|
+
margin-right 0.5u
|
|
9
|
+
|
|
10
|
+
&.l
|
|
11
|
+
&.xl
|
|
12
|
+
&.xxl
|
|
13
|
+
margin-right 1u
|
|
14
|
+
|
|
15
|
+
&.right
|
|
16
|
+
&.xs
|
|
17
|
+
&.s
|
|
18
|
+
&.m
|
|
19
|
+
margin-left 0.5u
|
|
20
|
+
|
|
21
|
+
&.l
|
|
22
|
+
&.xl
|
|
23
|
+
&.xxl
|
|
24
|
+
margin-left 1u
|
|
25
|
+
|
|
26
|
+
.item
|
|
27
|
+
align-items center
|
|
28
|
+
|
|
29
|
+
.separator
|
|
30
|
+
margin-left 2px
|
|
31
|
+
margin-right @margin-left
|
|
32
|
+
color var(--color-text-description)
|
|
33
|
+
|
|
34
|
+
.separator,
|
|
35
|
+
.content
|
|
36
|
+
&.xs
|
|
37
|
+
font-size 1.25u
|
|
38
|
+
line-height 1.75u
|
|
39
|
+
|
|
40
|
+
&.s
|
|
41
|
+
font(caption)
|
|
42
|
+
|
|
43
|
+
&.m
|
|
44
|
+
font(body2)
|
|
45
|
+
|
|
46
|
+
&.l
|
|
47
|
+
font(body1)
|
|
48
|
+
|
|
49
|
+
&.xl
|
|
50
|
+
font(h5)
|
|
51
|
+
|
|
52
|
+
&.xxl
|
|
53
|
+
font(h4)
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
// DO NOT MODIFY THIS FILE - IT IS AUTOMATICALLY GENERATED ON COMMITS.
|
|
3
|
+
|
|
4
|
+
import React, { type ReactNode } from 'react';
|
|
5
|
+
import { type StyleProp, type ViewStyle } from 'react-native';
|
|
6
|
+
import './index.cssx.styl';
|
|
7
|
+
type BreadcrumbsSize = 'xs' | 's' | 'm' | 'l' | 'xl' | 'xxl';
|
|
8
|
+
declare const _default: React.ComponentType<BreadcrumbsProps>;
|
|
9
|
+
export default _default;
|
|
10
|
+
export declare const _PropsJsonSchema: {};
|
|
11
|
+
export interface BreadcrumbRoute {
|
|
12
|
+
/** Path to navigate to */
|
|
13
|
+
to?: string;
|
|
14
|
+
/** Text label of the route */
|
|
15
|
+
name?: string;
|
|
16
|
+
/** Icon displayed next to the label */
|
|
17
|
+
icon?: object | (() => any);
|
|
18
|
+
}
|
|
19
|
+
export interface BreadcrumbsProps {
|
|
20
|
+
/** Custom styles applied to the root container */
|
|
21
|
+
style?: StyleProp<ViewStyle>;
|
|
22
|
+
/** List of breadcrumb routes to render */
|
|
23
|
+
routes?: BreadcrumbRoute[];
|
|
24
|
+
/** Separator displayed between routes @default '/' */
|
|
25
|
+
separator?: string | ReactNode;
|
|
26
|
+
/** Size preset controlling text and icon dimensions @default 'm' */
|
|
27
|
+
size?: BreadcrumbsSize;
|
|
28
|
+
/** Replace the current history entry instead of pushing */
|
|
29
|
+
replace?: boolean;
|
|
30
|
+
/** Icon position relative to the label @default 'left' */
|
|
31
|
+
iconPosition?: 'left' | 'right';
|
|
32
|
+
}
|
package/index.tsx
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import React, { type ReactNode } from 'react'
|
|
2
|
+
import { type StyleProp, type ViewStyle } from 'react-native'
|
|
3
|
+
import { pug, observer } from 'startupjs'
|
|
4
|
+
import { themed, useColors } from '@startupjs-ui/core'
|
|
5
|
+
import Div from '@startupjs-ui/div'
|
|
6
|
+
import Icon from '@startupjs-ui/icon'
|
|
7
|
+
import Link from '@startupjs-ui/link'
|
|
8
|
+
import Span from '@startupjs-ui/span'
|
|
9
|
+
import './index.cssx.styl'
|
|
10
|
+
|
|
11
|
+
type BreadcrumbsSize = 'xs' | 's' | 'm' | 'l' | 'xl' | 'xxl'
|
|
12
|
+
|
|
13
|
+
const DEPRECATED_SIZE_VALUES: BreadcrumbsSize[] = ['xs', 'xl', 'xxl']
|
|
14
|
+
|
|
15
|
+
export default observer(themed('Breadcrumbs', Breadcrumbs))
|
|
16
|
+
|
|
17
|
+
export const _PropsJsonSchema = {/* BreadcrumbsProps */}
|
|
18
|
+
|
|
19
|
+
export interface BreadcrumbRoute {
|
|
20
|
+
/** Path to navigate to */
|
|
21
|
+
to?: string
|
|
22
|
+
/** Text label of the route */
|
|
23
|
+
name?: string
|
|
24
|
+
/** Icon displayed next to the label */
|
|
25
|
+
icon?: object | (() => any)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface BreadcrumbsProps {
|
|
29
|
+
/** Custom styles applied to the root container */
|
|
30
|
+
style?: StyleProp<ViewStyle>
|
|
31
|
+
/** List of breadcrumb routes to render */
|
|
32
|
+
routes?: BreadcrumbRoute[]
|
|
33
|
+
/** Separator displayed between routes @default '/' */
|
|
34
|
+
separator?: string | ReactNode
|
|
35
|
+
/** Size preset controlling text and icon dimensions @default 'm' */
|
|
36
|
+
size?: BreadcrumbsSize
|
|
37
|
+
/** Replace the current history entry instead of pushing */
|
|
38
|
+
replace?: boolean
|
|
39
|
+
/** Icon position relative to the label @default 'left' */
|
|
40
|
+
iconPosition?: 'left' | 'right'
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function Breadcrumbs ({
|
|
44
|
+
style,
|
|
45
|
+
routes = [],
|
|
46
|
+
separator = '/',
|
|
47
|
+
size = 'm',
|
|
48
|
+
replace = false,
|
|
49
|
+
iconPosition = 'left'
|
|
50
|
+
}: BreadcrumbsProps): ReactNode {
|
|
51
|
+
if (DEPRECATED_SIZE_VALUES.includes(size)) {
|
|
52
|
+
console.warn(
|
|
53
|
+
`[@startupjs/ui] Breadcrumbs: size='${size}' is DEPRECATED, use one of 's', 'm', 'l' instead.`
|
|
54
|
+
)
|
|
55
|
+
}
|
|
56
|
+
const getColor = useColors()
|
|
57
|
+
|
|
58
|
+
function renderItem ({
|
|
59
|
+
icon,
|
|
60
|
+
color,
|
|
61
|
+
bold,
|
|
62
|
+
children
|
|
63
|
+
}: {
|
|
64
|
+
icon?: BreadcrumbRoute['icon']
|
|
65
|
+
color?: string
|
|
66
|
+
bold?: boolean
|
|
67
|
+
children?: ReactNode
|
|
68
|
+
}): ReactNode {
|
|
69
|
+
const extraStyle = { color }
|
|
70
|
+
return pug`
|
|
71
|
+
Div(vAlign='center' reverse=iconPosition === 'right' row)
|
|
72
|
+
if icon
|
|
73
|
+
Div.iconWrapper(styleName=[size, iconPosition])
|
|
74
|
+
Icon(style=extraStyle icon=icon size=size)
|
|
75
|
+
Span.content(
|
|
76
|
+
style=extraStyle
|
|
77
|
+
styleName=[size]
|
|
78
|
+
bold=bold
|
|
79
|
+
)= children
|
|
80
|
+
`
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return pug`
|
|
84
|
+
Div(style=style wrap row)
|
|
85
|
+
each route, index in routes
|
|
86
|
+
- const { name, icon, to } = route
|
|
87
|
+
- const isLastRoute = index === routes.length - 1
|
|
88
|
+
React.Fragment(key=index)
|
|
89
|
+
if isLastRoute
|
|
90
|
+
= renderItem({ icon, color: getColor('text-secondary'), bold: true, children: name })
|
|
91
|
+
else
|
|
92
|
+
Div.item(row)
|
|
93
|
+
Link(
|
|
94
|
+
replace=replace
|
|
95
|
+
to=to
|
|
96
|
+
)
|
|
97
|
+
= renderItem({ icon, color: getColor('text-description'), children: name })
|
|
98
|
+
if typeof separator === 'string'
|
|
99
|
+
Span.separator(styleName=[size])
|
|
100
|
+
|  #{separator} 
|
|
101
|
+
else
|
|
102
|
+
= separator
|
|
103
|
+
`
|
|
104
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@startupjs-ui/breadcrumbs",
|
|
3
|
+
"version": "0.1.3",
|
|
4
|
+
"publishConfig": {
|
|
5
|
+
"access": "public"
|
|
6
|
+
},
|
|
7
|
+
"main": "index.tsx",
|
|
8
|
+
"types": "index.d.ts",
|
|
9
|
+
"type": "module",
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"@startupjs-ui/core": "^0.1.3",
|
|
12
|
+
"@startupjs-ui/div": "^0.1.3",
|
|
13
|
+
"@startupjs-ui/icon": "^0.1.3",
|
|
14
|
+
"@startupjs-ui/link": "^0.1.3",
|
|
15
|
+
"@startupjs-ui/span": "^0.1.3"
|
|
16
|
+
},
|
|
17
|
+
"peerDependencies": {
|
|
18
|
+
"react": "*",
|
|
19
|
+
"react-native": "*",
|
|
20
|
+
"startupjs": "*"
|
|
21
|
+
},
|
|
22
|
+
"gitHead": "fd964ebc3892d3dd0a6c85438c0af619cc50c3f0"
|
|
23
|
+
}
|