@redocly/theme 0.19.4 → 0.19.6

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.
@@ -48,7 +48,7 @@ function CatalogCard({ item }) {
48
48
  React.createElement(CardFooter, null,
49
49
  hasTags && (React.createElement(CardTags, null,
50
50
  (item.tags || []).map((tag, index) => (React.createElement(CardTag, { key: tag + index, color: (0, utils_1.slug)(tag) },
51
- React.createElement(Highlight_1.Highlight, null, tag)))),
51
+ React.createElement(Highlight_1.Highlight, null, (0, utils_1.capitalize)(tag))))),
52
52
  (item.scorecardLevel && item.scorecardStatus && (React.createElement(CardTag, { color: statusToColor(item.scorecardStatus), className: "tag-variant-scorecard-level" },
53
53
  React.createElement(Highlight_1.Highlight, null, item.scorecardLevel)))) ||
54
54
  null)),
@@ -71,6 +71,7 @@ function statusToColor(status) {
71
71
  const SelectButton = styled_components_1.default.div `
72
72
  border: 1px solid var(--catalog-card-button-border-color);
73
73
  border-radius: 100%;
74
+ min-width: var(--catalog-card-button-width);
74
75
  width: var(--catalog-card-button-width);
75
76
  height: var(--catalog-card-button-height);
76
77
  display: flex;
@@ -147,6 +148,8 @@ const CardTags = styled_components_1.default.div `
147
148
  min-height: var(--spacing-xl);
148
149
  `;
149
150
  const CardTag = (0, styled_components_1.default)(Tag_1.Tag) `
151
+ display: block;
152
+ text-transform: inherit;
150
153
  margin: 0;
151
154
  `;
152
155
  //# sourceMappingURL=CatalogCard.js.map
@@ -74,7 +74,7 @@ function changeCasing(str, casing) {
74
74
  return str.toUpperCase();
75
75
  }
76
76
  if (casing === 'sentence') {
77
- const words = str.split(/[\s-_]+/);
77
+ const words = str === null || str === void 0 ? void 0 : str.split(/[\s-_]+/);
78
78
  return words.map((word) => word[0].toUpperCase() + word.slice(1).toLowerCase()).join(' ');
79
79
  }
80
80
  }
@@ -8,7 +8,7 @@ const react_1 = __importDefault(require("react"));
8
8
  const styled_components_1 = __importDefault(require("styled-components"));
9
9
  function parseSrcSet(srcSet) {
10
10
  const result = new Map();
11
- const parts = srcSet.split(', ');
11
+ const parts = srcSet === null || srcSet === void 0 ? void 0 : srcSet.split(', ');
12
12
  for (const part of parts) {
13
13
  const [url, theme] = part.split(' ');
14
14
  result.set(theme, url);
@@ -8,7 +8,8 @@ export interface ProfileProps {
8
8
  export declare const Profile: React.NamedExoticComponent<ProfileProps>;
9
9
  export declare const ProfileWrapper: import("styled-components").StyledComponent<"div", any, {
10
10
  'data-component-name': string;
11
- }, "data-component-name">;
11
+ 'data-cy': string;
12
+ }, "data-component-name" | "data-cy">;
12
13
  export declare const AvatarWrapper: import("styled-components").StyledComponent<"div", any, {
13
14
  background?: string | undefined;
14
15
  }, never>;
@@ -31,9 +31,9 @@ function ProfileComponent({ name = 'User', imageUrl, onClick }) {
31
31
  var _a;
32
32
  if (imageUrl) {
33
33
  return (react_1.default.createElement(exports.ProfileWrapper, { onClick: onClick, role: "link" }, imageUrl && (react_1.default.createElement(exports.AvatarWrapper, null,
34
- react_1.default.createElement("img", { "data-cy": "user-avatar", src: imageUrl, alt: "profile" })))));
34
+ react_1.default.createElement("img", { src: imageUrl, alt: "profile" })))));
35
35
  }
36
- const avatarLetters = `${name.charAt(0).toUpperCase()}${((_a = name.split(' ')[1]) === null || _a === void 0 ? void 0 : _a.charAt(0).toUpperCase()) || ''}`;
36
+ const avatarLetters = `${name === null || name === void 0 ? void 0 : name.charAt(0).toUpperCase()}${((_a = name === null || name === void 0 ? void 0 : name.split(' ')[1]) === null || _a === void 0 ? void 0 : _a.charAt(0).toUpperCase()) || ''}`;
37
37
  return (react_1.default.createElement(exports.ProfileWrapper, { onClick: onClick, role: "link" },
38
38
  react_1.default.createElement(exports.AvatarWrapper, { background: (0, utils_1.stringToHslColor)(name) },
39
39
  react_1.default.createElement("span", null, avatarLetters))));
@@ -41,6 +41,7 @@ function ProfileComponent({ name = 'User', imageUrl, onClick }) {
41
41
  exports.Profile = (0, react_1.memo)(ProfileComponent);
42
42
  exports.ProfileWrapper = styled_components_1.default.div.attrs(() => ({
43
43
  'data-component-name': 'Profile/Profile',
44
+ 'data-cy': 'user-profile',
44
45
  })) `
45
46
  display: flex;
46
47
  align-items: center;
@@ -67,6 +67,7 @@ exports.UserProfile = UserProfile;
67
67
  const ProfileDropdown = (0, styled_components_1.default)(Dropdown_1.Dropdown).attrs(() => ({
68
68
  dataAttributes: {
69
69
  'data-component-name': 'Profile/ProfileDropdown',
70
+ 'data-cy': 'user-profile-dropdown',
70
71
  },
71
72
  })) `
72
73
  font-size: var(--profile-dropdown-font-size);
@@ -10,3 +10,4 @@ export * from './color';
10
10
  export * from './urls';
11
11
  export * from './jsUtils';
12
12
  export * from './tags-parser';
13
+ export * from './text-transform';
@@ -26,4 +26,5 @@ __exportStar(require("./color"), exports);
26
26
  __exportStar(require("./urls"), exports);
27
27
  __exportStar(require("./jsUtils"), exports);
28
28
  __exportStar(require("./tags-parser"), exports);
29
+ __exportStar(require("./text-transform"), exports);
29
30
  //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ export declare function capitalize(input: string): string;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.capitalize = void 0;
4
+ function capitalize(input) {
5
+ return input.charAt(0).toUpperCase() + input.slice(1);
6
+ }
7
+ exports.capitalize = capitalize;
8
+ //# sourceMappingURL=text-transform.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redocly/theme",
3
- "version": "0.19.4",
3
+ "version": "0.19.6",
4
4
  "description": "Shared UI components lib",
5
5
  "keywords": [
6
6
  "theme",
@@ -7,7 +7,7 @@ import { Highlight } from '@theme/ui/Highlight';
7
7
  import { Tag } from '@theme/components/Tag';
8
8
  import { PointingArrowIcon } from '@theme/icons';
9
9
  import { telemetry } from '@portal/telemetry';
10
- import { slug } from '@theme/utils';
10
+ import { slug, capitalize } from '@theme/utils';
11
11
 
12
12
  export function CatalogCard({ item }: { item: CatalogItem }): JSX.Element {
13
13
  const hasTags = item.scorecardStatus || item.tags?.length;
@@ -26,7 +26,7 @@ export function CatalogCard({ item }: { item: CatalogItem }): JSX.Element {
26
26
  <CardTags>
27
27
  {((item.tags as string[]) || []).map((tag, index) => (
28
28
  <CardTag key={tag + index} color={slug(tag)}>
29
- <Highlight>{tag}</Highlight>
29
+ <Highlight>{capitalize(tag)}</Highlight>
30
30
  </CardTag>
31
31
  ))}
32
32
  {(item.scorecardLevel && item.scorecardStatus && (
@@ -66,6 +66,7 @@ function statusToColor(status: string) {
66
66
  const SelectButton = styled.div`
67
67
  border: 1px solid var(--catalog-card-button-border-color);
68
68
  border-radius: 100%;
69
+ min-width: var(--catalog-card-button-width);
69
70
  width: var(--catalog-card-button-width);
70
71
  height: var(--catalog-card-button-height);
71
72
  display: flex;
@@ -149,5 +150,7 @@ const CardTags = styled.div`
149
150
  `;
150
151
 
151
152
  const CardTag = styled(Tag)`
153
+ display: block;
154
+ text-transform: inherit;
152
155
  margin: 0;
153
156
  `;
@@ -142,7 +142,7 @@ function changeCasing(
142
142
  }
143
143
 
144
144
  if (casing === 'sentence') {
145
- const words = str.split(/[\s-_]+/);
145
+ const words = str?.split(/[\s-_]+/);
146
146
  return words.map((word) => word[0].toUpperCase() + word.slice(1).toLowerCase()).join(' ');
147
147
  }
148
148
  }
@@ -3,7 +3,7 @@ import styled from 'styled-components';
3
3
 
4
4
  function parseSrcSet(srcSet: string): Map<string, string> {
5
5
  const result = new Map<string, string>();
6
- const parts = srcSet.split(', ');
6
+ const parts = srcSet?.split(', ');
7
7
 
8
8
  for (const part of parts) {
9
9
  const [url, theme] = part.split(' ');
@@ -16,15 +16,15 @@ function ProfileComponent({ name = 'User', imageUrl, onClick }: ProfileProps): J
16
16
  <ProfileWrapper onClick={onClick} role="link">
17
17
  {imageUrl && (
18
18
  <AvatarWrapper>
19
- <img data-cy="user-avatar" src={imageUrl} alt="profile" />
19
+ <img src={imageUrl} alt="profile" />
20
20
  </AvatarWrapper>
21
21
  )}
22
22
  </ProfileWrapper>
23
23
  );
24
24
  }
25
25
 
26
- const avatarLetters = `${name.charAt(0).toUpperCase()}${
27
- name.split(' ')[1]?.charAt(0).toUpperCase() || ''
26
+ const avatarLetters = `${name?.charAt(0).toUpperCase()}${
27
+ name?.split(' ')[1]?.charAt(0).toUpperCase() || ''
28
28
  }`;
29
29
 
30
30
  return (
@@ -40,6 +40,7 @@ export const Profile = memo<ProfileProps>(ProfileComponent);
40
40
 
41
41
  export const ProfileWrapper = styled.div.attrs(() => ({
42
42
  'data-component-name': 'Profile/Profile',
43
+ 'data-cy': 'user-profile',
43
44
  }))`
44
45
  display: flex;
45
46
  align-items: center;
@@ -77,6 +77,7 @@ export function UserProfile({
77
77
  const ProfileDropdown = styled(Dropdown).attrs(() => ({
78
78
  dataAttributes: {
79
79
  'data-component-name': 'Profile/ProfileDropdown',
80
+ 'data-cy': 'user-profile-dropdown',
80
81
  },
81
82
  }))`
82
83
  font-size: var(--profile-dropdown-font-size);
@@ -10,3 +10,4 @@ export * from './color';
10
10
  export * from './urls';
11
11
  export * from './jsUtils';
12
12
  export * from './tags-parser';
13
+ export * from './text-transform';
@@ -0,0 +1,3 @@
1
+ export function capitalize(input: string): string {
2
+ return input.charAt(0).toUpperCase() + input.slice(1);
3
+ }