revdev-components 0.55.0 → 0.56.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,8 +1,24 @@
1
1
  import React from "react";
2
- interface Props {
2
+ import { FrontControlSelect } from "src/interfaces";
3
+ export interface FrontHeaderProps {
3
4
  children?: React.ReactNode;
4
5
  className?: string;
5
6
  logoHref: string;
7
+ loginHref: string;
8
+ registerHref: string;
9
+ language: FrontControlSelect;
10
+ text: {
11
+ login: string;
12
+ register: string;
13
+ portfolio: string;
14
+ settings: string;
15
+ logout: string;
16
+ };
17
+ user?: {
18
+ username: string;
19
+ profileHref: string;
20
+ settingsHref: string;
21
+ onLogOut: () => void;
22
+ };
6
23
  }
7
- export declare const FrontHeader: React.FC<Props>;
8
- export {};
24
+ export declare const FrontHeader: React.FC<FrontHeaderProps>;
package/build/index.js CHANGED
@@ -5046,17 +5046,11 @@ var RowDivision = function (_a) {
5046
5046
  return React.createElement("div", { className: classNames(s$3.root, className) }, children);
5047
5047
  };
5048
5048
 
5049
- var s$2 = {"root":"index-module_root__Q7VjD","content":"index-module_content__T-JEW"};
5049
+ var s$2 = {"root":"index-module_root__Q7VjD","root__shadow":"index-module_root__shadow__OhPad","logo":"index-module_logo__KCA1E","content":"index-module_content__T-JEW","link":"index-module_link__nXsvL","select":"index-module_select__22zW6"};
5050
5050
 
5051
- var FrontHeader = function (_a) {
5052
- var children = _a.children, className = _a.className, logoHref = _a.logoHref;
5053
- return (React.createElement("div", { className: classNames(s$2.root, className) },
5054
- React.createElement(AppLink, { className: s$2.logo, href: logoHref }, "AlfaSchool"),
5055
- React.createElement("div", { className: s$2.content }, children),
5056
- React.createElement("div", { className: s$2.right }, "Log Out")));
5057
- };
5051
+ var s$1 = {"popover":"index-module_popover__lwzdT","item":"index-module_item__pfayG"};
5058
5052
 
5059
- var s$1 = {"root":"index-module_root__UzFV2","column":"index-module_column__XEWzG","children":"index-module_children__y7-7m","flex":"index-module_flex__83M30","button":"index-module_button__U8D6K"};
5053
+ var s = {"root":"index-module_root__UzFV2","column":"index-module_column__XEWzG","children":"index-module_children__y7-7m","flex":"index-module_flex__83M30","button":"index-module_button__U8D6K"};
5060
5054
 
5061
5055
  var AppTooltip = function (_a) {
5062
5056
  var _b = _a.placement, placement = _b === void 0 ? "top" : _b, children = _a.children, props = __rest(_a, ["placement", "children"]);
@@ -5067,14 +5061,14 @@ var AppTooltip = function (_a) {
5067
5061
  var IconBoxContent = function (_a) {
5068
5062
  var _b;
5069
5063
  var flexRoot = _a.flexRoot, icon = _a.icon, rightIcon = _a.rightIcon, children = _a.children, className = _a.className, contentClassName = _a.contentClassName, onClick = _a.onClick, _c = _a.direction, direction = _c === void 0 ? "row" : _c, elementRev = _a.elementRev, style = _a.style;
5070
- return (React.createElement("div", { ref: elementRev, style: style, className: classNames(s$1.root, (_b = {},
5071
- _b[s$1.flex] = flexRoot,
5072
- _b[s$1.button] = !!onClick,
5073
- _b[s$1.column] = direction === "column",
5064
+ return (React.createElement("div", { ref: elementRev, style: style, className: classNames(s.root, (_b = {},
5065
+ _b[s.flex] = flexRoot,
5066
+ _b[s.button] = !!onClick,
5067
+ _b[s.column] = direction === "column",
5074
5068
  _b), className), onClick: onClick },
5075
- icon ? React.createElement(RegularIcon, { className: s$1.icon, name: icon }) : null,
5076
- children ? React.createElement("div", { className: classNames(contentClassName, s$1.root__children) }, children) : null,
5077
- rightIcon ? React.createElement(RegularIcon, { className: s$1.icon, name: rightIcon }) : null));
5069
+ icon ? React.createElement(RegularIcon, { className: s.icon, name: icon }) : null,
5070
+ children ? React.createElement("div", { className: classNames(contentClassName, s.root__children) }, children) : null,
5071
+ rightIcon ? React.createElement(RegularIcon, { className: s.icon, name: rightIcon }) : null));
5078
5072
  };
5079
5073
  var IconDivision = function (props) {
5080
5074
  var tooltip = props.tooltip, tooltipPlacement = props.tooltipPlacement, hoverOpenDelay = props.hoverOpenDelay;
@@ -5082,13 +5076,11 @@ var IconDivision = function (props) {
5082
5076
  React.createElement(IconBoxContent, __assign({}, props)))) : (React.createElement(IconBoxContent, __assign({}, props)));
5083
5077
  };
5084
5078
 
5085
- var s = {"popover":"index-module_popover__lwzdT","item":"index-module_item__pfayG"};
5086
-
5087
5079
  var PopoverSelect = function (_a) {
5088
- var options = _a.options, value = _a.value, onChange = _a.onChange, icon = _a.icon, renderOption = _a.renderOption;
5080
+ var options = _a.options, value = _a.value, onChange = _a.onChange, icon = _a.icon, renderOption = _a.renderOption, showValue = _a.showValue;
5089
5081
  var _b = React.useState(false), open = _b[0], setOpen = _b[1];
5090
5082
  var handleChange = React.useCallback(function (newValue) {
5091
- onChange(newValue);
5083
+ onChange === null || onChange === void 0 ? void 0 : onChange(newValue);
5092
5084
  setOpen(false);
5093
5085
  }, [open, onChange]);
5094
5086
  var handleOpen = React.useCallback(function () {
@@ -5100,11 +5092,60 @@ var PopoverSelect = function (_a) {
5100
5092
  var selectedOption = React.useMemo(function () {
5101
5093
  return options.find(function (x) { return x.value === value; });
5102
5094
  }, [options, value]);
5103
- var popoverContent = React.useMemo(function () { return (React.createElement("div", { className: s.popover }, options
5095
+ var popoverContent = React.useMemo(function () { return (React.createElement("div", { className: s$1.popover }, options
5104
5096
  .filter(function (x) { return x.value !== value; })
5105
- .map(function (x) { return (React.createElement(React.Fragment, { key: x.value }, renderOption ? (renderOption(x, { className: s.item, onClick: function () { return handleChange(x.value); } })) : (React.createElement("div", { className: s.item, onClick: function () { return handleChange(x.value); } }, x.label)))); }))); }, [options, value, handleChange, renderOption]);
5097
+ .map(function (x) { return (React.createElement(React.Fragment, { key: x.value }, renderOption ? (renderOption(x, { className: s$1.item, onClick: function () { return handleChange(x.value); } })) : (React.createElement("div", { className: s$1.item, onClick: function () { return handleChange(x.value); } }, x.label)))); }))); }, [options, value, handleChange, renderOption]);
5106
5098
  return (React.createElement(antd.Popover, { content: popoverContent, open: open, onOpenChange: closePopover, placement: "bottomRight" },
5107
- React.createElement(IconDivision, { icon: icon, onClick: handleOpen, rightIcon: open ? "expand-less" : "expand-more" }, selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.label)));
5099
+ React.createElement(IconDivision, { icon: icon, onClick: handleOpen, rightIcon: open ? "expand-less" : "expand-more" }, showValue ? value : selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.label)));
5100
+ };
5101
+
5102
+ var FrontHeader = function (_a) {
5103
+ var _b;
5104
+ var user = _a.user, children = _a.children, className = _a.className, logoHref = _a.logoHref, loginHref = _a.loginHref, registerHref = _a.registerHref, language = _a.language, text = _a.text;
5105
+ var _c = React.useState(false), shadow = _c[0], setShadow = _c[1];
5106
+ function handleScroll() {
5107
+ setShadow(window.scrollY > 50);
5108
+ }
5109
+ React.useEffect(function () {
5110
+ if (window) {
5111
+ window.addEventListener("scroll", handleScroll);
5112
+ return function () { return window.removeEventListener("scroll", handleScroll); };
5113
+ }
5114
+ }, []);
5115
+ var settingsOptions = React.useMemo(function () {
5116
+ return user
5117
+ ? [
5118
+ {
5119
+ value: user.profileHref,
5120
+ label: text.portfolio,
5121
+ },
5122
+ {
5123
+ value: user.settingsHref,
5124
+ label: text.settings,
5125
+ },
5126
+ {
5127
+ value: "logout",
5128
+ label: text.logout,
5129
+ },
5130
+ ]
5131
+ : [];
5132
+ }, [user, text]);
5133
+ var handleSettingRender = React.useCallback(function (_a, _b) {
5134
+ var value = _a.value, label = _a.label;
5135
+ var className = _b.className, onClick = _b.onClick;
5136
+ return value === "logout" ? (React.createElement("div", { className: className, onClick: function () { return onClick(value); } }, label)) : (React.createElement(AppLink, { href: value, className: className }, label));
5137
+ }, []);
5138
+ return (React.createElement("div", { className: classNames(s$2.root, (_b = {},
5139
+ _b[s$2.root__shadow] = shadow,
5140
+ _b), className) },
5141
+ React.createElement(AppLink, { className: s$2.logo, href: logoHref }, "AlfaSchool"),
5142
+ React.createElement("div", { className: s$2.content }, children),
5143
+ !user && (React.createElement("div", { className: s$2.link },
5144
+ React.createElement(AppLink, { href: loginHref }, text.login || "Login"),
5145
+ React.createElement(AppLink, { href: registerHref }, text.register || "Register"))),
5146
+ React.createElement("div", { className: s$2.select },
5147
+ user && React.createElement(PopoverSelect, { showValue: true, value: user.username, options: settingsOptions, renderOption: handleSettingRender }),
5148
+ React.createElement(PopoverSelect, __assign({ icon: "language" }, language)))));
5108
5149
  };
5109
5150
 
5110
5151
  exports.AppForm = AppForm;
@@ -1,5 +1,11 @@
1
1
  import React from "react";
2
+ import { ValueOption } from "./option";
2
3
  export interface HeaderProps {
3
4
  children: React.ReactNode;
4
5
  className?: string;
5
6
  }
7
+ export interface FrontControlSelect {
8
+ value: string;
9
+ options: ValueOption[];
10
+ onChange?: (newValue: string) => void;
11
+ }
@@ -9,9 +9,10 @@ export type PopoverSelectRenderOption<TOption = ValueOption> = (option: TOption,
9
9
  interface Props<TOption = ValueOption> {
10
10
  value: string;
11
11
  options: TOption[];
12
- onChange: (value: string) => void;
12
+ onChange?: (value: string) => void;
13
13
  icon?: RegularIconName;
14
14
  renderOption?: PopoverSelectRenderOption<TOption>;
15
+ showValue?: boolean;
15
16
  }
16
17
  export declare const PopoverSelect: React.FC<Props>;
17
18
  export {};
package/build/styles.css CHANGED
@@ -1,9 +1,23 @@
1
1
  :root {
2
+ --fontFamily: roboto, sans-serif;
2
3
  --color: #222;
3
- --headerBorderColor: #cecece88;
4
- --linkColor: #1f2f5a;
5
- --passiveColor: #aaa;
4
+ --passiveColor: #888;
5
+ --linkColor: #332e56;
6
+ --passiveLinkColor: #8c9eb8;
7
+ --backgroundColor: #fff;
8
+ --hoverBackgroundColor: #f2f2f2;
9
+ --optionBackgroundColor: #dcdee4;
10
+ --hoverOptionBackgroundColor: #c4c6cc;
11
+ --borderColor: #dadada;
12
+ --errorColor: #b50000;
13
+ --successColor: #32a800;
14
+ --errorBackgroundColor: #ffaaad;
15
+ --successBackgroundColor: #aae094;
16
+ --scrollTrackColor: #f2f2f2;
17
+ --scrollThumbColor: #e5e5e5;
18
+ --scrollThumbHoverColor: #d8d8d8;
6
19
  --spacing: 10px;
20
+ --headerBorderColor: #cecece88;
7
21
  --centralDivisionMaxWidth: 1000px;
8
22
  --frontHeaderHeight: 50px;
9
23
  --backSidebarBackgroundColor: rgb(58 63 81);
@@ -22,6 +36,7 @@
22
36
  html,
23
37
  body {
24
38
  color: var(--color);
39
+ font-family: var(--fontFamily);
25
40
  }
26
41
  .index-module_root__-LDR1 {
27
42
  display: inline-block;
@@ -356,15 +371,58 @@ body {
356
371
  .index-module_root__Q7VjD {
357
372
  display: flex;
358
373
  align-items: center;
359
- gap: var(--spacing);
374
+ gap: 16px;
360
375
  padding-left: var(--spacing);
361
376
  padding-right: var(--spacing);
362
377
  height: var(--frontHeaderHeight);
378
+ border-bottom: 1px solid var(--borderColor);
379
+ background-color: var(--backgroundColor);
380
+ }
381
+ .index-module_root__shadow__OhPad {
382
+ box-shadow: 0 0 15px var(--borderColor);
383
+ }
384
+
385
+ .index-module_logo__KCA1E {
386
+ font-weight: 800;
387
+ }
388
+ .index-module_logo__KCA1E:hover {
389
+ text-decoration: none !important;
363
390
  }
364
391
 
365
392
  .index-module_content__T-JEW {
366
393
  flex: 1;
367
394
  }
395
+
396
+ .index-module_link__nXsvL {
397
+ display: flex;
398
+ flex-direction: row;
399
+ gap: var(--spacing);
400
+ text-transform: uppercase;
401
+ }
402
+
403
+ .index-module_select__22zW6 {
404
+ display: flex;
405
+ flex-direction: row;
406
+ gap: var(--spacing);
407
+ }
408
+ .index-module_popover__lwzdT {
409
+ display: flex;
410
+ flex-direction: column;
411
+ }
412
+
413
+ .index-module_item__pfayG {
414
+ padding: 10px 15px;
415
+ cursor: pointer;
416
+ border-bottom: 1px solid var(--borderColor);
417
+ font-weight: 500;
418
+ font-size: 16px;
419
+ }
420
+ .index-module_item__pfayG:last-of-type {
421
+ border: none;
422
+ }
423
+ .index-module_item__pfayG:hover {
424
+ background-color: var(--hoverBackgroundColor);
425
+ }
368
426
  .index-module_root__UzFV2 {
369
427
  display: flex;
370
428
  align-items: center;
@@ -389,22 +447,4 @@ body {
389
447
 
390
448
  .index-module_button__U8D6K {
391
449
  cursor: pointer;
392
- }
393
- .index-module_popover__lwzdT {
394
- display: flex;
395
- flex-direction: column;
396
- }
397
-
398
- .index-module_item__pfayG {
399
- padding: 10px 15px;
400
- cursor: pointer;
401
- border-bottom: 1px solid var(--borderColor);
402
- font-weight: 500;
403
- font-size: 16px;
404
- }
405
- .index-module_item__pfayG:last-of-type {
406
- border: none;
407
- }
408
- .index-module_item__pfayG:hover {
409
- background-color: var(--hoverBackgroundColor);
410
450
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "revdev-components",
3
- "version": "0.55.0",
3
+ "version": "0.56.0",
4
4
  "main": "build/index.js",
5
5
  "module": "build/index.esm.js",
6
6
  "scripts": {
@@ -36,6 +36,7 @@
36
36
  "@storybook/addon-essentials": "^8.4.5",
37
37
  "@storybook/addon-interactions": "^8.4.5",
38
38
  "@storybook/addon-onboarding": "^8.4.5",
39
+ "@storybook/addon-viewport": "^8.5.8",
39
40
  "@storybook/blocks": "^8.4.5",
40
41
  "@storybook/nextjs": "^8.4.5",
41
42
  "@storybook/react": "^8.4.5",