@openfin/ui-library 0.1.22 → 0.1.23-alpha.1627330098
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/dist/components/layout/DefinitionList/definitionList.d.ts +1 -3
- package/dist/components/layout/DefinitionList/definitionList.js +16 -5
- package/dist/components/templates/ContactCard/contactCard.d.ts +24 -0
- package/dist/components/templates/ContactCard/contactCard.js +114 -0
- package/dist/components/templates/ContactCard/index.d.ts +1 -0
- package/dist/components/templates/ContactCard/index.js +13 -0
- package/dist/components/templates/utils/name.d.ts +2 -0
- package/dist/components/templates/utils/name.js +22 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +1 -1
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
export interface DefinitionListProps extends React.HTMLAttributes<HTMLDListElement> {
|
|
3
|
-
definitions:
|
|
4
|
-
[key: string]: string;
|
|
5
|
-
};
|
|
3
|
+
definitions: Map<string, string>;
|
|
6
4
|
}
|
|
7
5
|
export declare const DefinitionList: React.FC<DefinitionListProps>;
|
|
@@ -20,19 +20,30 @@ const react_1 = __importDefault(require("react"));
|
|
|
20
20
|
const styled_components_1 = __importDefault(require("styled-components"));
|
|
21
21
|
const DefinitionList = (_a) => {
|
|
22
22
|
var { definitions } = _a, rest = __rest(_a, ["definitions"]);
|
|
23
|
-
return (jsx_runtime_1.jsx(List, Object.assign({}, rest, { children:
|
|
23
|
+
return (jsx_runtime_1.jsx(List, Object.assign({}, rest, { children: Array.from(definitions.keys()).map((name, index) => {
|
|
24
24
|
return (jsx_runtime_1.jsxs(react_1.default.Fragment, { children: [jsx_runtime_1.jsx(Name, { children: name }, void 0),
|
|
25
|
-
jsx_runtime_1.jsx(Definition, { children: definitions
|
|
25
|
+
jsx_runtime_1.jsx(Definition, { children: definitions.get(name) }, void 0)] }, `${name}-${index}`));
|
|
26
26
|
}) }), void 0));
|
|
27
27
|
};
|
|
28
28
|
exports.DefinitionList = DefinitionList;
|
|
29
29
|
const List = styled_components_1.default.dl `
|
|
30
30
|
display: grid;
|
|
31
31
|
grid-template-columns: 1fr 3fr;
|
|
32
|
-
gap: ${({ theme }) => `0 ${theme.px.
|
|
32
|
+
gap: ${({ theme }) => `0 ${theme.px.large}`};
|
|
33
|
+
overflow-y: auto;
|
|
34
|
+
padding: ${({ theme }) => `${theme.px.small} ${theme.px.base}`};
|
|
35
|
+
word-break: break-word;
|
|
33
36
|
`;
|
|
34
37
|
const Name = styled_components_1.default.dt `
|
|
35
|
-
|
|
38
|
+
color: ${({ theme }) => theme.palette.textHelp};
|
|
39
|
+
font-size: ${({ theme }) => theme.fontSize.small};
|
|
40
|
+
font-weight: ${({ theme }) => theme.fontWeight.normal};
|
|
41
|
+
line-height: ${({ theme }) => theme.px.base};
|
|
42
|
+
padding-bottom: ${({ theme }) => theme.px.small};
|
|
36
43
|
white-space: nowrap;
|
|
37
44
|
`;
|
|
38
|
-
const Definition = styled_components_1.default.dd
|
|
45
|
+
const Definition = styled_components_1.default.dd `
|
|
46
|
+
font-size: ${({ theme }) => theme.fontSize.small};
|
|
47
|
+
line-height: ${({ theme }) => theme.px.base};
|
|
48
|
+
padding-bottom: ${({ theme }) => theme.px.small};
|
|
49
|
+
`;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface ContactCardProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
3
|
+
/**
|
|
4
|
+
* Name of the contact.
|
|
5
|
+
*/
|
|
6
|
+
name: string;
|
|
7
|
+
/**
|
|
8
|
+
* Title of the contact.
|
|
9
|
+
*/
|
|
10
|
+
title?: string;
|
|
11
|
+
/**
|
|
12
|
+
* URL for the contact's profile photo.
|
|
13
|
+
*/
|
|
14
|
+
photoUrl?: string;
|
|
15
|
+
/**
|
|
16
|
+
* A flag to indicate that the contact card should display the contact's initials as profile photo if the photo url is undefined.
|
|
17
|
+
*/
|
|
18
|
+
useInitials?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* An array of detail list objects that can be used for logical grouping of contact details.
|
|
21
|
+
*/
|
|
22
|
+
details: Map<string, string>[];
|
|
23
|
+
}
|
|
24
|
+
export declare const ContactCard: React.FC<ContactCardProps>;
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.ContactCard = void 0;
|
|
18
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
19
|
+
const react_1 = __importDefault(require("react"));
|
|
20
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
21
|
+
// import { getColorForName, getInitials } from '../utils/name';
|
|
22
|
+
const DefinitionList_1 = require("../../layout/DefinitionList");
|
|
23
|
+
const name_1 = require("../utils/name");
|
|
24
|
+
const ContactCard = (_a) => {
|
|
25
|
+
var { name, title, photoUrl, useInitials = false, details } = _a, rest = __rest(_a, ["name", "title", "photoUrl", "useInitials", "details"]);
|
|
26
|
+
const renderProfileImage = photoUrl || useInitials;
|
|
27
|
+
const initials = react_1.default.useMemo(() => name_1.getInitials(name), [name]);
|
|
28
|
+
const color = react_1.default.useMemo(() => name_1.getColorForName(name), [name]);
|
|
29
|
+
return (jsx_runtime_1.jsxs(Container, Object.assign({}, rest, { children: [jsx_runtime_1.jsxs(Header, { children: [renderProfileImage && (jsx_runtime_1.jsx(ProfileImage, Object.assign({ iconColor: color }, { children: photoUrl ? jsx_runtime_1.jsx(Photo, { alt: title, src: photoUrl }, void 0) : jsx_runtime_1.jsx(LetterIcon, { children: initials }, void 0) }), void 0)),
|
|
30
|
+
jsx_runtime_1.jsxs(Identity, { children: [jsx_runtime_1.jsxs(Name, { children: [" ", name, " "] }, void 0),
|
|
31
|
+
title && jsx_runtime_1.jsxs(Title, { children: [" ", title, " "] }, void 0)] }, void 0)] }, void 0),
|
|
32
|
+
jsx_runtime_1.jsx(DetailsPane, { children: details.map((list, index) => (jsx_runtime_1.jsxs(react_1.default.Fragment, { children: [jsx_runtime_1.jsx(DetailList, { definitions: list }, void 0),
|
|
33
|
+
index < details.length - 1 && jsx_runtime_1.jsx(HorizontalLine, {}, void 0)] }, `${name}-details-${index}`))) }, void 0)] }), void 0));
|
|
34
|
+
};
|
|
35
|
+
exports.ContactCard = ContactCard;
|
|
36
|
+
const Container = styled_components_1.default.div `
|
|
37
|
+
display: flex;
|
|
38
|
+
flex-direction: column;
|
|
39
|
+
height: 100%;
|
|
40
|
+
padding: ${({ theme }) => theme.px.base};
|
|
41
|
+
`;
|
|
42
|
+
const Header = styled_components_1.default.div `
|
|
43
|
+
border-bottom: solid 1px ${({ theme }) => theme.palette.background6};
|
|
44
|
+
display: flex;
|
|
45
|
+
margin-bottom: ${({ theme }) => theme.px.base};
|
|
46
|
+
padding-bottom: ${({ theme }) => theme.px.small};
|
|
47
|
+
`;
|
|
48
|
+
const ProfileImage = styled_components_1.default.div `
|
|
49
|
+
align-items: center;
|
|
50
|
+
background-color: ${(attrs) => attrs.iconColor};
|
|
51
|
+
border-radius: ${({ theme }) => theme.px.xsmall};
|
|
52
|
+
display: flex;
|
|
53
|
+
height: ${({ theme }) => theme.iconSize.xxxlarge};
|
|
54
|
+
justify-content: center;
|
|
55
|
+
margin-right: ${({ theme }) => theme.px.small};
|
|
56
|
+
width: ${({ theme }) => theme.iconSize.xxxlarge};
|
|
57
|
+
`;
|
|
58
|
+
const LetterIcon = styled_components_1.default.span `
|
|
59
|
+
font-size: ${({ theme }) => theme.fontSize.base};
|
|
60
|
+
text-transform: uppercase;
|
|
61
|
+
`;
|
|
62
|
+
const Photo = styled_components_1.default.img `
|
|
63
|
+
border-radius: ${({ theme }) => theme.px.xsmall};
|
|
64
|
+
height: ${({ theme }) => theme.iconSize.xxxlarge};
|
|
65
|
+
object-fit: cover;
|
|
66
|
+
user-select: none;
|
|
67
|
+
width: ${({ theme }) => theme.iconSize.xxxlarge};
|
|
68
|
+
`;
|
|
69
|
+
const Identity = styled_components_1.default.div `
|
|
70
|
+
display: flex;
|
|
71
|
+
flex-direction: column;
|
|
72
|
+
justify-content: center;
|
|
73
|
+
min-width: 0;
|
|
74
|
+
`;
|
|
75
|
+
const Name = styled_components_1.default.span `
|
|
76
|
+
font-size: ${({ theme }) => theme.fontSize.large};
|
|
77
|
+
line-height: ${({ theme }) => theme.px.large};
|
|
78
|
+
overflow: hidden;
|
|
79
|
+
padding-bottom: ${({ theme }) => theme.px.xsmall};
|
|
80
|
+
text-overflow: ellipsis;
|
|
81
|
+
white-space: nowrap;
|
|
82
|
+
`;
|
|
83
|
+
const Title = styled_components_1.default.span `
|
|
84
|
+
color: ${({ theme }) => theme.palette.textHelp};
|
|
85
|
+
line-height: ${({ theme }) => theme.px.base};
|
|
86
|
+
overflow: hidden;
|
|
87
|
+
padding-bottom: 2px;
|
|
88
|
+
text-overflow: ellipsis;
|
|
89
|
+
white-space: nowrap;
|
|
90
|
+
`;
|
|
91
|
+
const DetailsPane = styled_components_1.default.div `
|
|
92
|
+
background-color: ${({ theme }) => theme.palette.background5};
|
|
93
|
+
border-radius: 2px;
|
|
94
|
+
flex: 1;
|
|
95
|
+
overflow-y: auto;
|
|
96
|
+
padding: ${({ theme }) => theme.px.small};
|
|
97
|
+
`;
|
|
98
|
+
const HorizontalLine = styled_components_1.default.div `
|
|
99
|
+
border-bottom: solid 1px ${({ theme }) => theme.palette.background6};
|
|
100
|
+
margin-bottom: ${({ theme }) => theme.px.base};
|
|
101
|
+
`;
|
|
102
|
+
const DetailList = styled_components_1.default(DefinitionList_1.DefinitionList) `
|
|
103
|
+
dt {
|
|
104
|
+
text-align: left;
|
|
105
|
+
text-transform: capitalize;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
dd {
|
|
109
|
+
overflow: hidden;
|
|
110
|
+
text-align: right;
|
|
111
|
+
text-overflow: ellipsis;
|
|
112
|
+
white-space: nowrap;
|
|
113
|
+
}
|
|
114
|
+
`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './contactCard';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./contactCard"), exports);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getColorForName = exports.getInitials = void 0;
|
|
4
|
+
const getInitials = (name) => {
|
|
5
|
+
const trimmed = name.trim();
|
|
6
|
+
const lastWordPos = trimmed.lastIndexOf(' ');
|
|
7
|
+
if (lastWordPos > -1) {
|
|
8
|
+
return [trimmed.charAt(0), trimmed.charAt(lastWordPos + 1)].join('');
|
|
9
|
+
}
|
|
10
|
+
return trimmed.slice(0, 2);
|
|
11
|
+
};
|
|
12
|
+
exports.getInitials = getInitials;
|
|
13
|
+
const colors = ['#8C61FF', '#00CC88', '#FF8FB8', '#FF976B', '#FD5E60', '#36C3FE', '#5254FB'];
|
|
14
|
+
const getColorForName = (name = '') => {
|
|
15
|
+
let total = 0;
|
|
16
|
+
for (let i = 0; i < name.length; i++) {
|
|
17
|
+
const code = name.codePointAt(i);
|
|
18
|
+
total += code;
|
|
19
|
+
}
|
|
20
|
+
return colors[total % colors.length];
|
|
21
|
+
};
|
|
22
|
+
exports.getColorForName = getColorForName;
|
package/dist/index.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export * from './components/layout/Box';
|
|
|
11
11
|
export * from './components/layout/DefinitionList';
|
|
12
12
|
export * from './components/system/GlobalStyles';
|
|
13
13
|
export * from './components/system/ThemeProvider';
|
|
14
|
+
export * from './components/templates/ContactCard';
|
|
14
15
|
export * from './components/typography/Heading';
|
|
15
16
|
export * from './components/typography/Text';
|
|
16
17
|
export * from './hooks/useColorScheme';
|
package/dist/index.js
CHANGED
|
@@ -36,6 +36,7 @@ __exportStar(require("./components/layout/Box"), exports);
|
|
|
36
36
|
__exportStar(require("./components/layout/DefinitionList"), exports);
|
|
37
37
|
__exportStar(require("./components/system/GlobalStyles"), exports);
|
|
38
38
|
__exportStar(require("./components/system/ThemeProvider"), exports);
|
|
39
|
+
__exportStar(require("./components/templates/ContactCard"), exports);
|
|
39
40
|
__exportStar(require("./components/typography/Heading"), exports);
|
|
40
41
|
__exportStar(require("./components/typography/Text"), exports);
|
|
41
42
|
__exportStar(require("./hooks/useColorScheme"), exports);
|
package/package.json
CHANGED