@companycam/slab-web 1.0.0 → 1.2.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.
- package/index.d.ts +4 -0
- package/index.js +272 -43
- package/index.mjs +1520 -1051
- package/lib/Billboard/Billboard.d.ts +57 -0
- package/lib/Button/Button.d.ts +28 -0
- package/lib/InputText/InputText.d.ts +25 -0
- package/lib/ScreenReaderContent/ScreenReaderContent.d.ts +11 -0
- package/lib/shared/Field/Field.d.ts +15 -0
- package/lib/shared/styles.d.ts +1 -1
- package/package.json +9 -3
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { CSSProperties } from 'react';
|
|
2
|
+
import { ButtonProps } from '../Button/Button';
|
|
3
|
+
type IconColor = 'success' | 'caution' | 'destroy' | 'info';
|
|
4
|
+
type Action = Pick<ButtonProps, 'href' | 'onClick' | 'icon'> & {
|
|
5
|
+
label: string;
|
|
6
|
+
};
|
|
7
|
+
type Image = {
|
|
8
|
+
src: string;
|
|
9
|
+
alt: string;
|
|
10
|
+
imageContainerStyle?: CSSProperties;
|
|
11
|
+
};
|
|
12
|
+
export type BillboardProps = {
|
|
13
|
+
className?: string;
|
|
14
|
+
color?: IconColor;
|
|
15
|
+
iconName?: string;
|
|
16
|
+
message: string;
|
|
17
|
+
primaryAction?: Action;
|
|
18
|
+
secondaryAction?: Action;
|
|
19
|
+
style?: CSSProperties;
|
|
20
|
+
title?: string;
|
|
21
|
+
image?: Image;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Billboard renders any combination of an icon/image, title, message, and action buttons.
|
|
25
|
+
* - Use title case for the `title` (e.g., "Something Went Wrong", not "Something went wrong").
|
|
26
|
+
* - Use `outline` icon variants in Billboard where possible.
|
|
27
|
+
* - If the `message` is long enough, set a `max-width` by extending Billboard as a `styled-component`: `const StyledBillboard = styled(Billboard)({ maxWidth: '400px'; margin: 0 auto; });`
|
|
28
|
+
* - Images are sized to 128px by 128px. (Square images work best.)
|
|
29
|
+
*
|
|
30
|
+
*
|
|
31
|
+
* @param [alt] - A label for images used in billboard
|
|
32
|
+
* @param [color] - Determines the color of the icon (and primary button, if color is "destroy")
|
|
33
|
+
* @param [iconName] - Display a CompanyCam icon as the featured image
|
|
34
|
+
* @param [message] - The main text content
|
|
35
|
+
* @param [primaryAction] - Object with `label`, `onClick`, `href`, and `icon` for primary action button that pulls types from ```<Button />```
|
|
36
|
+
* @param [secondaryAction] - Object with `label`, `onClick`, `href`, and `icon` for secondary action button that pulls types from ```<Button />```
|
|
37
|
+
* @param [title] - The Billboard heading
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
*
|
|
41
|
+
* const clearError = () => {
|
|
42
|
+
* setError(null);
|
|
43
|
+
* };
|
|
44
|
+
*
|
|
45
|
+
*<Billboard
|
|
46
|
+
* title="Uh-Oh!"
|
|
47
|
+
* color="destroy"
|
|
48
|
+
* iconName="alert-circle"
|
|
49
|
+
* secondaryAction={{
|
|
50
|
+
* label: "Try, again",
|
|
51
|
+
* onClick: clearError,
|
|
52
|
+
* }}
|
|
53
|
+
* message="Sorry, something seems to have happened on our end."
|
|
54
|
+
* />
|
|
55
|
+
*/
|
|
56
|
+
export declare const Billboard: ({ image, className, color, iconName, message, primaryAction, secondaryAction, style, title, }: BillboardProps) => JSX.Element;
|
|
57
|
+
export default Billboard;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React, { ComponentPropsWithRef } from 'react';
|
|
2
|
+
type ButtonColor = 'destroy' | 'primary' | 'secondary' | 'subtle' | 'success';
|
|
3
|
+
type ButtonSize = 'small' | 'medium' | 'large';
|
|
4
|
+
declare const ButtonDesign: {
|
|
5
|
+
readonly solid: "solid";
|
|
6
|
+
readonly outline: "outline";
|
|
7
|
+
readonly minimal: "minimal";
|
|
8
|
+
};
|
|
9
|
+
type Design = (typeof ButtonDesign)[keyof typeof ButtonDesign];
|
|
10
|
+
type BaseButtonProps = ComponentPropsWithRef<'button'> & ComponentPropsWithRef<'a'>;
|
|
11
|
+
export type ButtonProps = BaseButtonProps & {
|
|
12
|
+
children: React.ReactNode;
|
|
13
|
+
color?: ButtonColor;
|
|
14
|
+
design?: Design;
|
|
15
|
+
href?: string;
|
|
16
|
+
icon?: {
|
|
17
|
+
name?: string;
|
|
18
|
+
position?: 'before' | 'after';
|
|
19
|
+
};
|
|
20
|
+
loading?: boolean;
|
|
21
|
+
size?: ButtonSize;
|
|
22
|
+
props?: unknown;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
Defaults to rendering as a `<button type="button" />`, but will render as a link if an href prop is provided.
|
|
26
|
+
*/
|
|
27
|
+
export declare const Button: ({ children, color, design, href, icon, loading, size, type, ...props }: ButtonProps) => JSX.Element;
|
|
28
|
+
export default Button;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { CSSProperties, ComponentPropsWithRef, ReactNode } from 'react';
|
|
2
|
+
type HTMLInputProps = ComponentPropsWithRef<'input'>;
|
|
3
|
+
type InputType = 'email' | 'search' | 'tel' | 'text' | 'url';
|
|
4
|
+
export type InputTextProps = HTMLInputProps & {
|
|
5
|
+
id: string;
|
|
6
|
+
label: ReactNode;
|
|
7
|
+
className?: string;
|
|
8
|
+
contentBefore?: ReactNode;
|
|
9
|
+
contentAfter?: ReactNode;
|
|
10
|
+
error?: boolean;
|
|
11
|
+
hideLabel?: boolean;
|
|
12
|
+
message?: ReactNode;
|
|
13
|
+
name?: string;
|
|
14
|
+
inputSize?: 'medium' | 'large';
|
|
15
|
+
style?: CSSProperties;
|
|
16
|
+
success?: boolean;
|
|
17
|
+
testId?: string;
|
|
18
|
+
type?: InputType;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* - InputText is a controlled component: You must provide an `onChange` handler to update the value.
|
|
22
|
+
* - Use title case for the required `label` (e.g., "Project Name", not "Project name").
|
|
23
|
+
*/
|
|
24
|
+
export declare function InputText({ className, contentBefore, contentAfter, error, hideLabel, id, label, message, name, inputSize, style, success, testId, type, ...props }: InputTextProps): JSX.Element;
|
|
25
|
+
export default InputText;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type ScreenReaderContentProps = {
|
|
2
|
+
children: React.ReactNode;
|
|
3
|
+
};
|
|
4
|
+
/**
|
|
5
|
+
|
|
6
|
+
#### When you're designing or implementing a UI, ask yourself if it could be used if you couldn't see the screen.
|
|
7
|
+
|
|
8
|
+
For example, is being able to see an icon important for the user to understand context or functionality? If so, always add explanatory text for screen readers, wrapped inside a `<ScreenReaderContent />` component.
|
|
9
|
+
*/
|
|
10
|
+
export declare const ScreenReaderContent: ({ children }: ScreenReaderContentProps) => JSX.Element;
|
|
11
|
+
export default ScreenReaderContent;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { CSSProperties, ReactNode } from 'react';
|
|
2
|
+
export type FieldProps = {
|
|
3
|
+
children: ReactNode;
|
|
4
|
+
className?: string;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
id: string;
|
|
7
|
+
message?: ReactNode;
|
|
8
|
+
status?: 'default' | 'error' | 'success';
|
|
9
|
+
style?: CSSProperties;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Field is used inside forms components like InputText as a DRY way of rendering a message below the input / label UI.
|
|
13
|
+
* */
|
|
14
|
+
export declare function Field({ children, className, disabled, id, message, status, style, }: FieldProps): JSX.Element;
|
|
15
|
+
export default Field;
|
package/lib/shared/styles.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare const systemFontFamily = "font-family: system-ui, -apple-system, BlinkMacSystemFont,\n'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;";
|
|
2
2
|
export declare const headingFontFamily = "font-family: 'Averta', system-ui, -apple-system, BlinkMacSystemFont,\n'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;";
|
|
3
|
-
export declare const focusStyles: import("styled-components").FlattenSimpleInterpolation;
|
|
3
|
+
export declare const focusStyles: (error?: boolean, success?: boolean) => import("styled-components").FlattenSimpleInterpolation;
|
|
4
4
|
export declare const baseButtonStyles: ({ disabled, readOnly }: {
|
|
5
5
|
disabled?: boolean | undefined;
|
|
6
6
|
readOnly?: boolean | undefined;
|
package/package.json
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@companycam/slab-web",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"main": "./index.js",
|
|
5
5
|
"types": "./index.d.ts",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": {
|
|
8
|
-
"import":
|
|
9
|
-
|
|
8
|
+
"import": {
|
|
9
|
+
"types": "./index.d.ts",
|
|
10
|
+
"default": "./index.mjs"
|
|
11
|
+
},
|
|
12
|
+
"require": {
|
|
13
|
+
"types": "./index.d.ts",
|
|
14
|
+
"default": "./index.js"
|
|
15
|
+
}
|
|
10
16
|
}
|
|
11
17
|
}
|
|
12
18
|
}
|