@jetbrains/kotlin-web-site-ui 4.2.0-alpha.4 → 4.3.0-alpha.0

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.
@@ -1,6 +1,7 @@
1
1
  import React__default, { forwardRef, useState, useMemo, useRef, useImperativeHandle, useLayoutEffect, useCallback, useEffect } from 'react';
2
2
  import { ThemeProvider } from '@rescui/ui-contexts';
3
3
  import FocusManager from '@rescui/focus-manager';
4
+ import useResizeObserver from '@react-hook/resize-observer';
4
5
  import OutsideClickHandler from 'react-outside-click-handler';
5
6
  import { LogoLarge } from './logo-large/logo-large.js';
6
7
  import styles from './header.module.pcss.js';
@@ -14,8 +15,14 @@ import classNames from 'classnames';
14
15
  import { SearchWrapper } from './search-wrapper/search-wrapper.js';
15
16
  import { isMacOs } from './is-macos.js';
16
17
  import { KEY_K_CODE } from './key-codes.js';
17
- import useResizeObserver from '@react-hook/resize-observer';
18
- const BREAKPOINT_XS = 640;
18
+ var SearchResultView;
19
+
20
+ (function (SearchResultView) {
21
+ SearchResultView[SearchResultView["Narrow"] = 0] = "Narrow";
22
+ SearchResultView[SearchResultView["Wide"] = 1] = "Wide";
23
+ })(SearchResultView || (SearchResultView = {}));
24
+
25
+ const MENU_POPUP_BREAKPOINT = 640;
19
26
  const Header = forwardRef(({
20
27
  productWebUrl,
21
28
  hasSearch = false,
@@ -27,7 +34,8 @@ const Header = forwardRef(({
27
34
  linkHandler,
28
35
  isPlayground,
29
36
  isUrlActive,
30
- searchConfig
37
+ searchConfig,
38
+ resultViewType = SearchResultView.Narrow
31
39
  }, forwardedRef) => {
32
40
  const [menuPopupExpanded, setMenuPopupExpanded] = useState(false);
33
41
  const [isSearchBoxVisible, setSearchBoxVisible] = useState(false);
@@ -38,9 +46,9 @@ const Header = forwardRef(({
38
46
  useImperativeHandle(forwardedRef, () => headerRef.current);
39
47
  const [isMenuPopupVisible, setMenuPopupVisible] = useState(false);
40
48
  useLayoutEffect(() => {
41
- setMenuPopupVisible((headerRef.current?.getBoundingClientRect?.().width ?? 0) <= BREAKPOINT_XS);
49
+ setMenuPopupVisible((headerRef.current?.getBoundingClientRect?.().width ?? 0) <= MENU_POPUP_BREAKPOINT);
42
50
  }, [headerRef]);
43
- useResizeObserver(headerRef, entry => setMenuPopupVisible(entry.contentRect.width <= BREAKPOINT_XS));
51
+ useResizeObserver(headerRef, entry => setMenuPopupVisible(entry.contentRect.width <= MENU_POPUP_BREAKPOINT));
44
52
  const handleSearchButtonClick = useCallback(() => {
45
53
  setSearchBoxVisible(!isSearchBoxVisible);
46
54
  }, []);
@@ -60,7 +68,7 @@ const Header = forwardRef(({
60
68
  }
61
69
  }, []);
62
70
  useEffect(() => {
63
- if (typeof document !== `undefined`) {
71
+ if (typeof document !== `undefined` && resultViewType === SearchResultView.Narrow) {
64
72
  document.addEventListener('keydown', fullSearchKeyHandler);
65
73
  const focusManager = new FocusManager();
66
74
  return () => {
@@ -91,7 +99,8 @@ const Header = forwardRef(({
91
99
  closeHandler: handleSearchClose,
92
100
  isMobile: isMenuPopupVisible,
93
101
  fullSearchActive: fullSearchActive,
94
- setFullSearchActive: setFullSearchActive
102
+ setFullSearchActive: setFullSearchActive,
103
+ searchBoxViewType: resultViewType
95
104
  })) : React__default.createElement(React__default.Fragment, null, !isMenuPopupVisible && React__default.createElement(HorizontalMenu, {
96
105
  items: itemsWithoutHomeSection,
97
106
  theme: dropdownTheme,
@@ -107,4 +116,4 @@ const Header = forwardRef(({
107
116
  linkHandler: linkHandler
108
117
  })))));
109
118
  });
110
- export { Header };
119
+ export { Header, SearchResultView };
@@ -56,7 +56,7 @@
56
56
  }
57
57
 
58
58
  .ktl-header-module_border_paN11 {
59
- box-shadow: inset 0 -1px rgba(255, 255, 255, 0.2);
59
+ box-shadow: inset 0 -1px rgba(255, 255, 255, 0.3);
60
60
  }
61
61
 
62
62
  @media (max-width: 640px) {
@@ -411,18 +411,39 @@
411
411
  transform: translateY(100%);
412
412
  }
413
413
 
414
+
414
415
  @media (min-width: 640px) and (max-width: 768px) {
415
416
  .ktl-quick-search-module_wrapper_kkbQQ {
416
417
  bottom: 12px;
417
418
  }
418
419
  }
419
420
 
421
+
420
422
  @media (min-width: 768px) {
421
423
  .ktl-quick-search-module_wrapper_kkbQQ {
422
424
  left: 0;
423
425
  right: 0;
424
426
  }
425
427
  }
428
+
429
+
430
+ @media (min-width: 640px) and (max-width: 1024px) {
431
+ .ktl-quick-search-module_apiReferenceWrapper_jv98t {
432
+ width: calc(100vw - 64px);
433
+ left: auto;
434
+ right: 0;
435
+ }
436
+ }
437
+
438
+
439
+ @media (min-width: 1024px) {
440
+ .ktl-quick-search-module_apiReferenceWrapper_jv98t {
441
+ left: auto;
442
+ right: 0;
443
+ width: 1000px;
444
+ }
445
+ }
446
+
426
447
  .ktl-loading-module_loader_B2IQl {
427
448
  margin-top: 4px;
428
449
  }
@@ -683,7 +704,7 @@
683
704
 
684
705
  .ktl-menu-popup-module_menu-popup_Q68IE {
685
706
  display: none;
686
- padding: 8px 0;
707
+ padding: 8px 0 56px 0;
687
708
  background: var(--ktl-dark-100);
688
709
  position: fixed;
689
710
  top: var(--ktl-header-height-mobile);
@@ -751,19 +772,13 @@
751
772
  font-size: 19px;
752
773
  line-height: 28px;
753
774
  font-weight: 400;
754
- color: rgba(255, 255, 255, 0.75);
775
+ color: #ffffff;
755
776
  text-decoration: none;
756
- padding: 12px 16px 12px 16px;
777
+ padding: 12px 7px 12px 16px;
757
778
  transition: color var(--ktl-transition-xfast),
758
779
  background-color var(--ktl-transition-xfast);
759
780
  }
760
781
 
761
- .ktl-menu-list-item-module_menu-item_Aruue:hover {
762
- color: rgba(255, 255, 255, 1);
763
- background: rgba(255, 255, 255, 0.1);
764
- text-decoration: none;
765
- }
766
-
767
782
  .ktl-menu-list-item-module_menu-item_Aruue.ktl-menu-list-item-module_active_jHfJR {
768
783
  color: var(--ktl-light-text-hard);
769
784
  background: rgba(255, 255, 255, 1);
@@ -805,8 +820,8 @@
805
820
  }
806
821
 
807
822
  .ktl-menu-list-module_menu-item-group_mFvUE {
808
- margin: 8px 0;
809
- padding: 8px 0;
823
+ margin: 8px 0 8px 0;
824
+ padding: 4px 0 8px 0;
810
825
  border-top: 1px solid rgba(255, 255, 255, 0.3);
811
826
  }
812
827
 
@@ -837,7 +852,6 @@
837
852
  }
838
853
 
839
854
  .ktl-logo-small-module_icon_NyEog {
840
- width: 24px;
841
- height: 24px;
842
- margin-left: -4px;
855
+ width: 20px;
856
+ height: 20px;
843
857
  }
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
 
3
- var _radialGradient, _path;
3
+ var _path, _defs;
4
4
 
5
5
  function _extends() {
6
6
  _extends = Object.assign || function (target) {
@@ -21,27 +21,29 @@ function _extends() {
21
21
  }
22
22
 
23
23
  const SvgKotlinLogoSmall = props => /*#__PURE__*/React.createElement("svg", _extends({
24
- xmlns: "http://www.w3.org/2000/svg",
25
- viewBox: "0 0 24 24"
26
- }, props), _radialGradient || (_radialGradient = /*#__PURE__*/React.createElement("radialGradient", {
24
+ width: 20,
25
+ height: 20,
26
+ fill: "none",
27
+ xmlns: "http://www.w3.org/2000/svg"
28
+ }, props), _path || (_path = /*#__PURE__*/React.createElement("path", {
29
+ d: "M20 20H0V0h20L9.793 9.855 20 20Z",
30
+ fill: "url(#kotlin-logo-small_svg__a)"
31
+ })), _defs || (_defs = /*#__PURE__*/React.createElement("defs", null, /*#__PURE__*/React.createElement("radialGradient", {
27
32
  id: "kotlin-logo-small_svg__a",
28
- cx: 22.432,
29
- cy: 3.493,
30
- r: 21.679,
31
- gradientTransform: "translate(-.19 .042) scale(.9998)",
32
- gradientUnits: "userSpaceOnUse"
33
+ cx: 0,
34
+ cy: 0,
35
+ r: 1,
36
+ gradientUnits: "userSpaceOnUse",
37
+ gradientTransform: "translate(19.335 .822) scale(22.9097)"
33
38
  }, /*#__PURE__*/React.createElement("stop", {
34
39
  offset: 0.003,
35
- stopColor: "#e44857"
40
+ stopColor: "#EF4857"
36
41
  }), /*#__PURE__*/React.createElement("stop", {
37
42
  offset: 0.469,
38
- stopColor: "#c711e1"
43
+ stopColor: "#D211EC"
39
44
  }), /*#__PURE__*/React.createElement("stop", {
40
45
  offset: 1,
41
- stopColor: "#7f52ff"
42
- }))), _path || (_path = /*#__PURE__*/React.createElement("path", {
43
- fill: "url(#kotlin-logo-small_svg__a)",
44
- d: "M22.87 21.68H3.94V2.76h18.93l-9.66 9.32z"
45
- })));
46
+ stopColor: "#7F52FF"
47
+ })))));
46
48
 
47
49
  export { SvgKotlinLogoSmall as default };
@@ -4,17 +4,19 @@ import { useTextStyles } from '@rescui/typography';
4
4
  import classNames from 'classnames';
5
5
  import { isMacOs } from '../../is-macos.js';
6
6
  import styles from './list.module.pcss.js';
7
+ import { SearchResultView } from '../../header.js';
7
8
 
8
9
  const ResultsList = ({
9
10
  results,
10
11
  searchString,
11
- toggleFullSearch
12
+ toggleFullSearch,
13
+ resultListViewType
12
14
  }) => {
13
15
  const textCn = useTextStyles();
14
16
  return React__default.createElement("div", {
15
- className: styles.results,
17
+ className: classNames(styles.results),
16
18
  "data-test": 'quick-search-results'
17
- }, results.length ? React__default.createElement(React__default.Fragment, null, React__default.createElement("div", {
19
+ }, results.length ? React__default.createElement(React__default.Fragment, null, resultListViewType === SearchResultView.Narrow && React__default.createElement("div", {
18
20
  className: styles.topBar
19
21
  }, React__default.createElement("div", {
20
22
  className: classNames(textCn('rs-text-3'), styles.searchString)
@@ -1,5 +1,6 @@
1
1
  import React__default from 'react';
2
2
  import { ThemeProvider } from '@rescui/ui-contexts';
3
+ import classNames from 'classnames';
3
4
  import { ResultsList } from './list/list.js';
4
5
  import { EmptyResult } from './empty/empty.js';
5
6
  import { LoadingResults } from './loading/loading.js';
@@ -9,13 +10,18 @@ const QuickSearch = ({
9
10
  results,
10
11
  searchString,
11
12
  toggleFullSearch,
12
- placeholder
13
+ placeholder,
14
+ quickSearchBoxViewType
13
15
  }) => {
16
+ const wrapperClassName = classNames(styles.wrapper, {
17
+ [styles.apiReferenceWrapper]: quickSearchBoxViewType
18
+ });
19
+
14
20
  if (placeholder) {
15
21
  return React__default.createElement(ThemeProvider, {
16
22
  theme: 'dark'
17
23
  }, React__default.createElement("div", {
18
- className: styles.wrapper
24
+ className: wrapperClassName
19
25
  }, React__default.createElement(EmptyResult, {
20
26
  placeholder: placeholder
21
27
  })));
@@ -25,16 +31,17 @@ const QuickSearch = ({
25
31
  return React__default.createElement(ThemeProvider, {
26
32
  theme: 'dark'
27
33
  }, React__default.createElement("div", {
28
- className: styles.wrapper
34
+ className: wrapperClassName
29
35
  }, React__default.createElement(ResultsList, {
30
36
  results: results,
31
37
  searchString: searchString,
32
- toggleFullSearch: toggleFullSearch
38
+ toggleFullSearch: toggleFullSearch,
39
+ resultListViewType: quickSearchBoxViewType
33
40
  })));
34
41
  }
35
42
 
36
43
  return React__default.createElement("div", {
37
- className: styles.wrapper
44
+ className: wrapperClassName
38
45
  }, React__default.createElement(LoadingResults, null));
39
46
  };
40
47
 
@@ -1,4 +1,5 @@
1
1
  var styles = {
2
- "wrapper": "ktl-quick-search-module_wrapper_kkbQQ"
2
+ "wrapper": "ktl-quick-search-module_wrapper_kkbQQ",
3
+ "apiReferenceWrapper": "ktl-quick-search-module_apiReferenceWrapper_jv98t"
3
4
  };
4
5
  export { styles as default };
@@ -6,7 +6,7 @@ const Result = ({
6
6
  hit
7
7
  }) => {
8
8
  const textCn = useTextStyles();
9
- const hitTitle = hit.title === hit.mainTitle ? hit.highlightedTitle : `${hit.mainTitle}: ${hit.highlightedTitle}`;
9
+ const hitTitle = !hit.mainTitle || hit.title === hit.mainTitle ? hit.highlightedTitle : `${hit.mainTitle}: ${hit.highlightedTitle}`;
10
10
  return React__default.createElement("a", {
11
11
  className: styles.result,
12
12
  href: hit.url
@@ -11,13 +11,14 @@ const SearchBox = ({
11
11
  closeHandler,
12
12
  isMobile,
13
13
  fullSearchActive,
14
- setFullSearchActive
14
+ setFullSearchActive,
15
+ searchBoxViewType
15
16
  }) => {
16
17
  const [searchInput, setSearchInput] = useState('');
17
18
  const {
18
19
  hits,
19
20
  placeholder
20
- } = useSearch(searchInput, 25);
21
+ } = useSearch(searchInput, fullSearchActive ? 25 : 75);
21
22
  const escHandler = useCallback(event => {
22
23
  if (event.keyCode === ESC_CODE) {
23
24
  closeHandler();
@@ -62,7 +63,8 @@ const SearchBox = ({
62
63
  results: hits,
63
64
  searchString: searchInput,
64
65
  toggleFullSearch: toggleFullSearch,
65
- placeholder: placeholder
66
+ placeholder: placeholder,
67
+ quickSearchBoxViewType: searchBoxViewType
66
68
  }), fullSearchActive && React__default.createElement(FullSearch, {
67
69
  toggleFullSearch: toggleFullSearch,
68
70
  searchString: searchInput,
@@ -30,14 +30,14 @@
30
30
  height: 64px;
31
31
  background: #ffffff;
32
32
  padding: 0 32px;
33
- box-shadow: inset 0 -1px 0 0 var(--ktl-light-dark-20);
33
+ box-shadow: inset 0 -1px 0 0 rgba(255, 255, 255, 0.3);
34
34
  transition: color var(--ktl-transition-fast),
35
35
  background-color var(--ktl-transition-fast);
36
36
  }
37
37
 
38
38
  .ktl-top-menu-module_top-menu-dark-theme_aNBxr {
39
39
  background: #1b1b1b;
40
- box-shadow: inset 0 -1px 0 0 rgba(255, 255, 255, 0.2);
40
+ box-shadow: inset 0 -1px 0 0 rgba(255, 255, 255, 0.3);
41
41
  }
42
42
 
43
43
  .ktl-top-menu-module_logo_CNH2W {
@@ -109,7 +109,7 @@
109
109
  .ktl-vertical-menu-module_button_zqr20 {
110
110
  border: none;
111
111
  background: none;
112
- height: 100%;
112
+ height: 52px;
113
113
  width: 100%;
114
114
  max-width: 100%;
115
115
  padding: 0;
@@ -117,6 +117,7 @@
117
117
  display: flex;
118
118
  align-items: center;
119
119
  cursor: pointer;
120
+ color: #fff;
120
121
  }
121
122
 
122
123
  .ktl-vertical-menu-module_button-text_aXith {
@@ -126,9 +127,9 @@
126
127
  }
127
128
 
128
129
  .ktl-vertical-menu-module_icon_-Ieat {
129
- width: 12px;
130
- height: 6px;
131
- margin-left: 6px;
130
+ width: 14px;
131
+ height: 8px;
132
+ margin-left: 13px;
132
133
  transition: transform ease-in-out var(--ktl-transition-xfast);
133
134
  flex: 0 0 auto;
134
135
  }
@@ -144,6 +145,7 @@
144
145
  border-bottom: 1px solid rgba(255, 255, 255, 0.3);
145
146
  justify-content: space-between;
146
147
  background: #ffffff;
148
+ margin-bottom: 8px;
147
149
  }
148
150
 
149
151
  .ktl-vertical-menu-module_dropdown-list_N3KWV {
@@ -47,11 +47,13 @@ const VerticalMenu = ({
47
47
  [styles.dropdownMenuExpanded]: isExpanded
48
48
  })
49
49
  }, React__default.createElement("button", {
50
- className: classNames(styles.button, textCn('rs-text-2')),
50
+ className: classNames(styles.button),
51
51
  "aria-haspopup": "true",
52
52
  onClick: handleOpen
53
53
  }, React__default.createElement("span", {
54
- className: styles.buttonText
54
+ className: textCn('rs-text-2', {
55
+ hardness: 'hard'
56
+ })
55
57
  }, activeItem.title), React__default.createElement(SvgArrowDropdownIcon, {
56
58
  className: styles.icon
57
59
  })), !!portalRoot && isExpanded && createPortal(React__default.createElement(VerticalMenuDropDown, {
@@ -108,7 +110,9 @@ const VerticalMenuDropDown = ({
108
110
  })), items.map((item, index) => React__default.createElement("a", {
109
111
  key: item.url,
110
112
  href: item.url,
111
- className: classNames(styles.dropdownItem, textCn('rs-text-1'), {
113
+ className: classNames(styles.dropdownItem, textCn('rs-text-1', {
114
+ hardness: 'hard'
115
+ }), {
112
116
  [styles.dropdownItemActive]: index === activeIndex
113
117
  }),
114
118
  onClick: event => linkHandler?.(event, item.url),
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@jetbrains/kotlin-web-site-ui",
3
3
  "description": "UI components for Kotlin web sites development",
4
- "version": "4.2.0-alpha.4",
4
+ "version": "4.3.0-alpha.0",
5
5
  "license": "Apache-2.0",
6
6
  "author": "JetBrains",
7
7
  "files": [
@@ -47,7 +47,7 @@
47
47
  "@babel/preset-typescript": "^7.13.0",
48
48
  "@babel/register": "^7.11.5",
49
49
  "@react-hook/resize-observer": "^1.2.5",
50
- "@rescui/button": "^0.6.9",
50
+ "@rescui/button": "^0.2.1",
51
51
  "@rescui/checkbox": "^0.1.0",
52
52
  "@rescui/focus-manager": "^0.1.1",
53
53
  "@rescui/icons": "^0.8.2",