-
Notifications
You must be signed in to change notification settings - Fork 78
Expand file tree
/
Copy pathAttachmentCardGroup.tsx
More file actions
65 lines (61 loc) · 1.73 KB
/
AttachmentCardGroup.tsx
File metadata and controls
65 lines (61 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { mergeStyles, Stack } from '@fluentui/react';
import { _pxToRem } from '@internal/acs-ui-common';
import React from 'react';
import { _ATTACHMENT_CARD_MARGIN_IN_PX, _ATTACHMENT_CARD_WIDTH_IN_REM } from '../styles/AttachmentCard.styles';
import {
attachmentCardBaseStyles,
attachmentCardFlexLayout,
attachmentCardGirdLayout,
attachmentGroupDisabled
} from '../styles/AttachmentCardGroup.styles';
/**
* @internal
* Props for `_AttachmentCardGroup` component.
*/
export enum _AttachmentCardGroupLayout {
/**
* Children are rendered in a grid layout with self resizing.
*/
Grid = 'grid',
/**
* Children are rendered in a flex layout with no resizing.
*/
Flex = 'flex'
}
/**
* @internal
* Props for `_AttachmentCardGroup` component.
*/
export interface _AttachmentCardGroupProps {
children: React.ReactNode;
ariaLabel?: string;
attachmentGroupLayout?: _AttachmentCardGroupLayout;
disabled?: boolean;
}
/**
* @internal
* Used with `_AttachmentCard` component where `_AttachmentCard` components are passed as children.
* Renders the children equally spaced in multiple rows.
*/
export const _AttachmentCardGroup = (props: _AttachmentCardGroupProps): JSX.Element => {
const { children, ariaLabel, attachmentGroupLayout, disabled } = props;
if (!children) {
return <></>;
}
return (
<Stack
horizontal
className={mergeStyles(
disabled && attachmentGroupDisabled,
attachmentCardBaseStyles,
attachmentGroupLayout === _AttachmentCardGroupLayout.Grid ? attachmentCardGirdLayout : attachmentCardFlexLayout
)}
aria-label={ariaLabel}
role="list"
>
{children}
</Stack>
);
};