diff --git a/webapp/channels/src/components/section_notice.test.tsx b/webapp/channels/src/components/section_notice/index.test.tsx similarity index 98% rename from webapp/channels/src/components/section_notice.test.tsx rename to webapp/channels/src/components/section_notice/index.test.tsx index f78695ff0bf..12dc634cb54 100644 --- a/webapp/channels/src/components/section_notice.test.tsx +++ b/webapp/channels/src/components/section_notice/index.test.tsx @@ -7,7 +7,7 @@ import React from 'react'; import {renderWithContext} from 'tests/react_testing_utils'; -import SectionNotice from './section_notice'; +import SectionNotice from '.'; type Props = ComponentProps; diff --git a/webapp/channels/src/components/section_notice.tsx b/webapp/channels/src/components/section_notice/index.tsx similarity index 58% rename from webapp/channels/src/components/section_notice.tsx rename to webapp/channels/src/components/section_notice/index.tsx index f34d19dbcf8..3ca58e905a1 100644 --- a/webapp/channels/src/components/section_notice.tsx +++ b/webapp/channels/src/components/section_notice/index.tsx @@ -7,25 +7,25 @@ import {useIntl} from 'react-intl'; import Markdown from 'components/markdown'; +import SectionNoticeButton from './section_notice_button'; +import type {SectionNoticeButtonProp} from './types'; + import './section_notice.scss'; -type Button = { - onClick: () => void; - text: string; -} type Props = { title: string | React.ReactElement; text?: string; - primaryButton?: Button; - secondaryButton?: Button; - linkButton?: Button; - type?: 'info' | 'success' | 'danger' | 'welcome' | 'warning'; + primaryButton?: SectionNoticeButtonProp; + secondaryButton?: SectionNoticeButtonProp; + linkButton?: SectionNoticeButtonProp; + type?: 'info' | 'success' | 'danger' | 'welcome' | 'warning' | 'hint'; isDismissable?: boolean; onDismissClick?: () => void; }; const iconByType = { info: 'icon-information-outline', + hint: 'icon-lightbulb-outline', success: 'icon-check', danger: 'icon-alert-outline', warning: 'icon-alert-outline', @@ -45,7 +45,7 @@ const SectionNotice = ({ const intl = useIntl(); const icon = iconByType[type]; const showDismiss = Boolean(isDismissable && onDismissClick); - const buttonClass = 'btn btn-sm sectionNoticeButton'; + const hasButtons = Boolean(primaryButton || secondaryButton || linkButton); return (
@@ -53,32 +53,26 @@ const SectionNotice = ({

{title}

{text && } - {(primaryButton || secondaryButton || linkButton) && ( + {hasButtons && (
- {primaryButton && ( - - )} - {secondaryButton && ( - - )} - {linkButton && ( - - )} + {primaryButton && + + } + {secondaryButton && + + } + {linkButton && + + }
)}
diff --git a/webapp/channels/src/components/section_notice.scss b/webapp/channels/src/components/section_notice/section_notice.scss similarity index 98% rename from webapp/channels/src/components/section_notice.scss rename to webapp/channels/src/components/section_notice/section_notice.scss index 7978d4b533e..8d3c72604d8 100644 --- a/webapp/channels/src/components/section_notice.scss +++ b/webapp/channels/src/components/section_notice/section_notice.scss @@ -8,7 +8,7 @@ margin: 0; } - &.info { + &.info, &.hint { border-color: rgba(var(--sidebar-text-active-border-rgb), 0.16); background: rgba(var(--sidebar-text-active-border-rgb), 0.08); @@ -76,7 +76,7 @@ .sectionNoticeIcon { font-size: 20px; - &.info { + &.info, &.hint { color: var(--sidebar-text-active-border); } diff --git a/webapp/channels/src/components/section_notice/section_notice_button.tsx b/webapp/channels/src/components/section_notice/section_notice_button.tsx new file mode 100644 index 00000000000..203d43c0518 --- /dev/null +++ b/webapp/channels/src/components/section_notice/section_notice_button.tsx @@ -0,0 +1,33 @@ +// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. +// See LICENSE.txt for license information. + +import classNames from 'classnames'; +import React from 'react'; + +import type {SectionNoticeButtonProp} from './types'; + +type Props = { + button: SectionNoticeButtonProp; + buttonClass: 'btn-primary' | 'btn-tertiary' | 'btn-link'; +} + +const SectionNoticeButton = ({ + button, + buttonClass, +}: Props) => { + const leading = button.leadingIcon ? () : null; + const trailing = button.trailingIcon ? () : null; + return ( + + ); +}; + +export default SectionNoticeButton; diff --git a/webapp/channels/src/components/section_notice/types.ts b/webapp/channels/src/components/section_notice/types.ts new file mode 100644 index 00000000000..9a91823c08a --- /dev/null +++ b/webapp/channels/src/components/section_notice/types.ts @@ -0,0 +1,10 @@ +// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. +// See LICENSE.txt for license information. + +export type SectionNoticeButtonProp = { + onClick: () => void; + text: string; + trailingIcon?: string; + leadingIcon?: string; + loading?: boolean; +}