2021-03-30 18:57:55 +02:00
|
|
|
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
|
|
// See LICENSE.txt for license information.
|
|
|
|
import React from 'react'
|
|
|
|
|
2021-07-06 19:53:54 +02:00
|
|
|
import {Constants} from '../constants'
|
|
|
|
|
2021-03-30 18:57:55 +02:00
|
|
|
import './label.scss'
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
color?: string
|
|
|
|
title?: string
|
|
|
|
children: React.ReactNode
|
2021-06-03 22:48:16 +02:00
|
|
|
classNames?: string
|
2021-03-30 18:57:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Switch is an on-off style switch / checkbox
|
|
|
|
function Label(props: Props): JSX.Element {
|
2021-07-06 19:53:54 +02:00
|
|
|
let color = 'empty'
|
|
|
|
if (props.color && props.color in Constants.menuColors) {
|
|
|
|
color = props.color
|
|
|
|
}
|
2021-03-30 18:57:55 +02:00
|
|
|
return (
|
|
|
|
<span
|
2021-07-06 19:53:54 +02:00
|
|
|
className={`Label ${color} ${props.classNames ? props.classNames : ''}`}
|
2021-03-30 18:57:55 +02:00
|
|
|
title={props.title}
|
|
|
|
>
|
|
|
|
{props.children}
|
|
|
|
</span>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export default React.memo(Label)
|