From 3a491feddecb7b152dedaa0147e3c107b62c32e7 Mon Sep 17 00:00:00 2001 From: Bill Date: Fri, 11 Mar 2022 00:08:17 -0500 Subject: [PATCH] Update common components --- src/common/Base.tsx | 4 +- src/common/card/NitroCardView.scss | 6 +- .../accordion/NitroCardAccordionItemView.tsx | 18 ++--- .../accordion/NitroCardAccordionSetView.tsx | 70 +++++++------------ .../card/accordion/NitroCardAccordionView.tsx | 17 +---- src/common/index.scss | 9 +-- .../layout/LayoutNotificationBubbleView.tsx | 8 +-- 7 files changed, 46 insertions(+), 86 deletions(-) diff --git a/src/common/Base.tsx b/src/common/Base.tsx index 7de14604..72ee2c27 100644 --- a/src/common/Base.tsx +++ b/src/common/Base.tsx @@ -1,10 +1,10 @@ import { CSSProperties, DetailedHTMLProps, FC, HTMLAttributes, LegacyRef, useMemo } from 'react'; -import { ColorVariantType, FloatType, OverflowType, PositionType } from './types'; +import { ColorVariantType, DisplayType, FloatType, OverflowType, PositionType } from './types'; export interface BaseProps extends DetailedHTMLProps, T> { innerRef?: LegacyRef; - display?: string; + display?: DisplayType; fit?: boolean; grow?: boolean; shrink?: boolean; diff --git a/src/common/card/NitroCardView.scss b/src/common/card/NitroCardView.scss index 8396f41b..c8440bb3 100644 --- a/src/common/card/NitroCardView.scss +++ b/src/common/card/NitroCardView.scss @@ -150,15 +150,11 @@ $nitro-card-tabs-height: 33px; border-bottom: $nav-tabs-border-width solid $nav-tabs-border-color; } -.nitro-card-accordion { - display: flex; - height: 100%; -} - .nitro-card-accordion-set { &.active { height: 100%; + overflow: hidden; background: rgba($white, 0.5); border-bottom: 1px solid rgba($black, 0.2); } diff --git a/src/common/card/accordion/NitroCardAccordionItemView.tsx b/src/common/card/accordion/NitroCardAccordionItemView.tsx index 5816f8b1..dbd89cc2 100644 --- a/src/common/card/accordion/NitroCardAccordionItemView.tsx +++ b/src/common/card/accordion/NitroCardAccordionItemView.tsx @@ -1,21 +1,17 @@ -import { FC, useMemo } from 'react'; +import { FC } from 'react'; import { Flex, FlexProps } from '../..'; -export const NitroCardAccordionItemView: FC = props => +export interface NitroCardAccordionItemViewProps extends FlexProps { - const { alignItems = 'center', gap = 1, classNames = [], children = null, ...rest } = props; - const getClassNames = useMemo(() => - { - const newClassNames: string[] = [ 'px-2, py-1' ]; +} - if(classNames.length) newClassNames.push(...classNames); - - return newClassNames; - }, [ classNames ]); +export const NitroCardAccordionItemView: FC = props => +{ + const { alignItems = 'center', gap = 1, children = null, ...rest } = props; return ( - + { children } ); diff --git a/src/common/card/accordion/NitroCardAccordionSetView.tsx b/src/common/card/accordion/NitroCardAccordionSetView.tsx index 66bb38b2..05dde76b 100644 --- a/src/common/card/accordion/NitroCardAccordionSetView.tsx +++ b/src/common/card/accordion/NitroCardAccordionSetView.tsx @@ -1,9 +1,9 @@ -import classNames from 'classnames'; +import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { FC, useCallback, useEffect, useMemo, useState } from 'react'; -import { Base, BaseProps, Flex } from '../..'; +import { Column, ColumnProps, Flex, Text } from '../..'; import { useNitroCardAccordionContext } from './NitroCardAccordionContext'; -interface NitroCardAccordionSetViewProps extends BaseProps +export interface NitroCardAccordionSetViewProps extends ColumnProps { headerText: string; isExpanded?: boolean; @@ -11,44 +11,29 @@ interface NitroCardAccordionSetViewProps extends BaseProps export const NitroCardAccordionSetView: FC = props => { - const { headerText = '', isExpanded = false, className = '', children = null, ...rest } = props; + const { headerText = '', isExpanded = false, gap = 0, classNames = [], children = null, ...rest } = props; const [ isOpen, setIsOpen ] = useState(false); const { setClosers = null, closeAll = null } = useNitroCardAccordionContext(); - const getClassName = useMemo(() => - { - let newClassName = 'nitro-card-accordion-set'; - - if(isOpen) newClassName += ' active'; - - if(className && className.length) newClassName += ` ${ className }`; - - return newClassName; - }, [ className, isOpen ]); - - const onClick = useCallback(() => + const onClick = () => { closeAll(); setIsOpen(prevValue => !prevValue); - // if(isOpen) - // { - // closeAll(); - // } - // else - // { - // BatchUpdates(() => - // { - // closeAll(); - // setIsOpen(true); - // }); - // } - }, [ closeAll ]); + } - const close = useCallback(() => + const close = useCallback(() => setIsOpen(false), []); + + const getClassNames = useMemo(() => { - setIsOpen(false); - }, []); + const newClassNames = [ 'nitro-card-accordion-set' ]; + + if(isOpen) newClassNames.push('active'); + + if(classNames && classNames.length) newClassNames.push(...classNames); + + return newClassNames; + }, [ isOpen, classNames ]); useEffect(() => { @@ -84,18 +69,15 @@ export const NitroCardAccordionSetView: FC = pro }, [ close, setClosers ]); return ( - - -
- { headerText } -
-
- -
+ + + { headerText } + - - { children } - - + { isOpen && + + { children } + } + ); } diff --git a/src/common/card/accordion/NitroCardAccordionView.tsx b/src/common/card/accordion/NitroCardAccordionView.tsx index 4f6a22d4..648a2e7d 100644 --- a/src/common/card/accordion/NitroCardAccordionView.tsx +++ b/src/common/card/accordion/NitroCardAccordionView.tsx @@ -1,4 +1,4 @@ -import { FC, useCallback, useMemo, useState } from 'react'; +import { FC, useCallback, useState } from 'react'; import { Column, ColumnProps } from '../..'; import { NitroCardAccordionContextProvider } from './NitroCardAccordionContext'; @@ -9,18 +9,9 @@ interface NitroCardAccordionViewProps extends ColumnProps export const NitroCardAccordionView: FC = props => { - const { className = '', children = null, ...rest } = props; + const { ...rest } = props; const [ closers, setClosers ] = useState([]); - const getClassName = useMemo(() => - { - let newClassName = 'nitro-card-accordion text-black'; - - if(className && className.length) newClassName += ` ${ className }`; - - return newClassName; - }, [ className ]); - const closeAll = useCallback(() => { for(const closer of closers) closer(); @@ -28,9 +19,7 @@ export const NitroCardAccordionView: FC = props => return ( - - { children } - + ); } diff --git a/src/common/index.scss b/src/common/index.scss index 856edd26..78935910 100644 --- a/src/common/index.scss +++ b/src/common/index.scss @@ -209,12 +209,9 @@ font-size: $font-size-sm; margin-bottom: 5px; - .bubble-image { - width: 30px; - height: 30px; - overflow: hidden; - object-fit: none; - margin-right: 5px; + .bubble-image-container { + min-width: 50px; + min-height: 50px; } } diff --git a/src/common/layout/LayoutNotificationBubbleView.tsx b/src/common/layout/LayoutNotificationBubbleView.tsx index 43fab73c..cac5b760 100644 --- a/src/common/layout/LayoutNotificationBubbleView.tsx +++ b/src/common/layout/LayoutNotificationBubbleView.tsx @@ -1,8 +1,8 @@ import { FC, useEffect, useMemo, useState } from 'react'; -import { Base, BaseProps } from '..'; +import { Flex, FlexProps } from '..'; import { TransitionAnimation, TransitionAnimationTypes } from '../transitions'; -interface LayoutNotificationBubbleViewProps extends BaseProps +interface LayoutNotificationBubbleViewProps extends FlexProps { fadesOut?: boolean; timeoutMs?: number; @@ -11,7 +11,7 @@ interface LayoutNotificationBubbleViewProps extends BaseProps export const LayoutNotificationBubbleView: FC = props => { - const { fadesOut = true, timeoutMs = 8000, close = null, classNames = [], ...rest } = props; + const { fadesOut = false, timeoutMs = 8000, close = null, overflow='hidden', classNames = [], ...rest } = props; const [ isVisible, setIsVisible ] = useState(false); const getClassNames = useMemo(() => @@ -46,7 +46,7 @@ export const LayoutNotificationBubbleView: FC return ( - + ); }