@brillout/docpress 0.8.6 → 0.8.8

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.
@@ -99,6 +99,7 @@ function headingToNavItem(heading: HeadingResolved | HeadingDetachedResolved): N
99
99
  title: heading.title,
100
100
  titleInNav: heading.titleInNav,
101
101
  menuModalFullWidth: heading.menuModalFullWidth,
102
+ color: heading.color,
102
103
  }
103
104
  }
104
105
  function headingToLinkData(heading: HeadingResolved | HeadingDetachedResolved): LinkData {
@@ -83,6 +83,7 @@ function headingToNavItem(heading) {
83
83
  title: heading.title,
84
84
  titleInNav: heading.titleInNav,
85
85
  menuModalFullWidth: heading.menuModalFullWidth,
86
+ color: heading.color,
86
87
  };
87
88
  }
88
89
  function headingToLinkData(heading) {
@@ -4,9 +4,11 @@ export type { NavItemAll };
4
4
  import React from 'react';
5
5
  import './Navigation.css';
6
6
  import '@docsearch/css';
7
+ import '../global.d.ts';
7
8
  type NavItem = {
8
9
  level: number;
9
10
  url?: string | null;
11
+ color?: string;
10
12
  title: string;
11
13
  titleInNav: string;
12
14
  menuModalFullWidth?: true;
@@ -17,6 +17,7 @@ import './Navigation.css';
17
17
  import { parseTitle } from '../parseTitle';
18
18
  import { usePageContext } from '../renderer/usePageContext';
19
19
  import '@docsearch/css';
20
+ import '../global.d.ts';
20
21
  function NavigationContent(props) {
21
22
  var pageContext = usePageContext();
22
23
  var navItemsWithComputed = getNavItemsWithComputed(props.navItems, pageContext.urlPathname);
@@ -36,23 +37,35 @@ function NavigationContent(props) {
36
37
  display: 'flex',
37
38
  justifyContent: 'center',
38
39
  } },
39
- React.createElement("div", { className: "column-layout-".concat(i), style: {
40
+ React.createElement("div", { className: "column-layout-".concat(i) + (!isFullWidth ? '' : ' nav-category'), style: {
40
41
  flexGrow: 1,
41
42
  columnGap: 20,
42
43
  paddingBottom: isFullWidth ? paddingBottom_1 : undefined,
43
- } }, navItemsColumnEntries.map(function (navItemColumnEntry, j) { return (React.createElement("div", { key: j, className: "column-layout-entry", style: {
44
- breakInside: 'avoid',
45
- paddingBottom: !isFullWidth ? paddingBottom_1 : undefined,
46
- width: '100%',
47
44
  } },
48
- React.createElement(NavItemComponent, { navItem: navItemColumnEntry }),
49
- navItemColumnEntry.navItemChilds.map(function (navItem, k) { return (React.createElement(NavItemComponent, { navItem: navItem, key: k })); }))); }))));
45
+ React.createElement(CategoryBorder, { navItemLevel1: !isFullWidth ? undefined : navItemsColumnEntries[0], paddingBottom: paddingBottom_1 }),
46
+ navItemsColumnEntries.map(function (navItemColumnEntry, j) { return (React.createElement("div", { key: j, className: 'column-layout-entry' + (isFullWidth ? '' : ' nav-category'), style: {
47
+ breakInside: 'avoid',
48
+ paddingBottom: !isFullWidth ? paddingBottom_1 : undefined,
49
+ width: '100%',
50
+ } },
51
+ React.createElement(CategoryBorder, { navItemLevel1: isFullWidth ? undefined : navItemColumnEntry, paddingBottom: paddingBottom_1 }),
52
+ React.createElement(NavItemComponent, { navItem: navItemColumnEntry }),
53
+ navItemColumnEntry.navItemChilds.map(function (navItem, k) { return (React.createElement(NavItemComponent, { navItem: navItem, key: k })); }))); }))));
50
54
  })));
51
55
  }
52
56
  return (React.createElement("div", { className: "navigation-content", style: { marginTop: 10 } }, navContent));
53
57
  }
58
+ function CategoryBorder(_a) {
59
+ var navItemLevel1 = _a.navItemLevel1, paddingBottom = _a.paddingBottom;
60
+ return !navItemLevel1 ? null : (React.createElement("div", { className: "category-border", style: {
61
+ width: 6,
62
+ background: navItemLevel1.color,
63
+ height: "calc(100% - ".concat(paddingBottom, "px - 13px)"),
64
+ } }));
65
+ }
54
66
  function NavItemComponent(_a) {
55
67
  var _b;
68
+ var _c;
56
69
  var navItem = _a.navItem;
57
70
  assert([1, 2, 3, 4].includes(navItem.level), navItem);
58
71
  var titleJsx = parseTitle(navItem.title);
@@ -71,7 +84,7 @@ function NavItemComponent(_a) {
71
84
  ].join(' '));
72
85
  }
73
86
  var props = {
74
- href: (_b = navItem.url) !== null && _b !== void 0 ? _b : undefined,
87
+ href: (_c = navItem.url) !== null && _c !== void 0 ? _c : undefined,
75
88
  children: titleInNavJsx,
76
89
  className: [
77
90
  'nav-item',
@@ -83,6 +96,11 @@ function NavItemComponent(_a) {
83
96
  .filter(Boolean)
84
97
  .join(' '),
85
98
  };
99
+ if (navItem.level === 1) {
100
+ props.style = (_b = {},
101
+ _b['--category-color'] = navItem.color,
102
+ _b);
103
+ }
86
104
  if (navItem.level === 2 || navItem.level === 3) {
87
105
  return React.createElement("a", __assign({}, props));
88
106
  }
@@ -11,6 +11,7 @@ type HeadingResolved = {
11
11
  sectionTitles?: string[];
12
12
  menuModalFullWidth?: true;
13
13
  category?: string;
14
+ color?: string;
14
15
  } & Tmp;
15
16
  type HeadingDetachedResolved = Omit<HeadingResolved, 'level' | 'linkBreadcrumb'> & {
16
17
  level: 2;
@@ -35,6 +36,7 @@ type IsCategory = {
35
36
  };
36
37
  type HeadingDefinitionLevel = ({
37
38
  level: 1;
39
+ color: string;
38
40
  } & IsCategory) | ({
39
41
  level: 4;
40
42
  } & IsCategory) | {
@@ -4,6 +4,9 @@
4
4
  overflow-x: hidden;
5
5
  --padding-left-global: 9px;
6
6
  }
7
+ #menu-modal .nav-item {
8
+ --padding-left-global: 15px;
9
+ }
7
10
  .nav-item code {
8
11
  font-size: 0.9em;
9
12
  }
@@ -19,7 +22,6 @@
19
22
  letter-spacing: 0.15ch;
20
23
  padding-left: var(--padding-left-global);
21
24
  padding-right: 4px;
22
- text-decoration: none;
23
25
  }
24
26
  .nav-item-level-1 {
25
27
  font-size: 19px;
@@ -30,10 +32,12 @@
30
32
  padding: 12px 0;
31
33
  padding-left: calc(var(--padding-left-global) - 2px);
32
34
  padding-right: 4px;
33
- text-decoration: none;
35
+ text-decoration: underline;
36
+ text-underline-offset: .2em;
37
+ text-decoration-thickness: .18em;
38
+ text-decoration-color: var(--category-color);
34
39
  }
35
40
  .nav-item-level-2 {
36
- text-decoration: none;
37
41
  font-size: 14.4px;
38
42
  font-weight: 400;
39
43
  letter-spacing: 0.15ch;
@@ -49,11 +53,10 @@
49
53
  font-weight: 400;
50
54
  letter-spacing: 0.15ch;
51
55
  color: var(--color-text);
52
- text-decoration: none;
53
56
  --padding: 5px;
54
57
 
55
58
  padding: var(--padding) 0;
56
- padding-left: calc(var(--padding-left-global) + 6px);
59
+ padding-left: calc(var(--padding-left-global) + 5px);
57
60
  }
58
61
  #menu-modal .nav-item-level-3 {
59
62
  border-right: 4px solid #eee;
@@ -94,3 +97,12 @@
94
97
  z-index: 1;
95
98
  content: "";
96
99
  }
100
+
101
+ .nav-category {
102
+ position: relative
103
+ }
104
+ .category-border {
105
+ position: absolute;
106
+ top: 0;
107
+ transform: translate(0, 13px);
108
+ }
@@ -10,10 +10,12 @@ import './Navigation.css'
10
10
  import { parseTitle } from '../parseTitle'
11
11
  import { usePageContext } from '../renderer/usePageContext'
12
12
  import '@docsearch/css'
13
+ import '../global.d.ts'
13
14
 
14
15
  type NavItem = {
15
16
  level: number
16
17
  url?: string | null
18
+ color?: string
17
19
  title: string
18
20
  titleInNav: string
19
21
  menuModalFullWidth?: true
@@ -49,23 +51,31 @@ function NavigationContent(props: {
49
51
  }}
50
52
  >
51
53
  <div
52
- className={`column-layout-${i}`}
54
+ className={`column-layout-${i}` + (!isFullWidth ? '' : ' nav-category')}
53
55
  style={{
54
56
  flexGrow: 1,
55
57
  columnGap: 20,
56
58
  paddingBottom: isFullWidth ? paddingBottom : undefined,
57
59
  }}
58
60
  >
61
+ <CategoryBorder
62
+ navItemLevel1={!isFullWidth ? undefined : navItemsColumnEntries[0]!}
63
+ paddingBottom={paddingBottom}
64
+ />
59
65
  {navItemsColumnEntries.map((navItemColumnEntry, j) => (
60
66
  <div
61
67
  key={j}
62
- className="column-layout-entry"
68
+ className={'column-layout-entry' + (isFullWidth ? '' : ' nav-category')}
63
69
  style={{
64
70
  breakInside: 'avoid',
65
71
  paddingBottom: !isFullWidth ? paddingBottom : undefined,
66
72
  width: '100%',
67
73
  }}
68
74
  >
75
+ <CategoryBorder
76
+ navItemLevel1={isFullWidth ? undefined : navItemColumnEntry!}
77
+ paddingBottom={paddingBottom}
78
+ />
69
79
  <NavItemComponent navItem={navItemColumnEntry} />
70
80
  {navItemColumnEntry.navItemChilds.map((navItem, k) => (
71
81
  <NavItemComponent navItem={navItem} key={k} />
@@ -85,6 +95,18 @@ function NavigationContent(props: {
85
95
  </div>
86
96
  )
87
97
  }
98
+ function CategoryBorder({ navItemLevel1, paddingBottom }: { navItemLevel1?: NavItemComputed; paddingBottom: number }) {
99
+ return !navItemLevel1 ? null : (
100
+ <div
101
+ className="category-border"
102
+ style={{
103
+ width: 6,
104
+ background: navItemLevel1.color!,
105
+ height: `calc(100% - ${paddingBottom}px - 13px)`,
106
+ }}
107
+ />
108
+ )
109
+ }
88
110
 
89
111
  function NavItemComponent({
90
112
  navItem,
@@ -125,6 +147,11 @@ function NavItemComponent({
125
147
  .filter(Boolean)
126
148
  .join(' '),
127
149
  }
150
+ if (navItem.level === 1) {
151
+ props.style = {
152
+ ['--category-color']: navItem.color!,
153
+ }
154
+ }
128
155
  type PropsAnchor = React.HTMLProps<HTMLAnchorElement>
129
156
  type PropsSpan = React.HTMLProps<HTMLSpanElement>
130
157
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brillout/docpress",
3
- "version": "0.8.6",
3
+ "version": "0.8.8",
4
4
  "type": "module",
5
5
  "dependencies": {
6
6
  "@brillout/picocolors": "^1.0.10",
package/types/Heading.ts CHANGED
@@ -12,6 +12,7 @@ type HeadingResolved = {
12
12
  sectionTitles?: string[]
13
13
  menuModalFullWidth?: true
14
14
  category?: string
15
+ color?: string
15
16
  } & Tmp
16
17
 
17
18
  type HeadingDetachedResolved = Omit<HeadingResolved, 'level' | 'linkBreadcrumb'> & {
@@ -40,7 +41,7 @@ type IsCategory = {
40
41
  titleInNav?: undefined
41
42
  }
42
43
  type HeadingDefinitionLevel =
43
- | ({ level: 1 } & IsCategory)
44
+ | ({ level: 1; color: string } & IsCategory)
44
45
  | ({ level: 4 } & IsCategory)
45
46
  | {
46
47
  level: 2