From 04227e7fb70f60710deb44e64aadf1a7ddc8e9fb Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Fri, 27 Dec 2019 10:58:16 +1100 Subject: [PATCH] make the leftpane header a bit more generic to handle tabs --- stylesheets/_session_theme_dark.scss | 9 +- .../_session_theme_dark_left_pane.scss | 5 + .../session/LeftPaneMessageSection.tsx | 22 +++-- .../session/LeftPaneSectionHeader.tsx | 96 +++++++++++++++++++ 4 files changed, 122 insertions(+), 10 deletions(-) create mode 100644 ts/components/session/LeftPaneSectionHeader.tsx diff --git a/stylesheets/_session_theme_dark.scss b/stylesheets/_session_theme_dark.scss index 43932d261..5645d0c2b 100644 --- a/stylesheets/_session_theme_dark.scss +++ b/stylesheets/_session_theme_dark.scss @@ -67,30 +67,37 @@ } @mixin session-h-title { - color: $session-color-white; font-weight: bold; } h1 { @include session-h-title; + color: $session-shade-16; font-size: 25px; margin: 0; + + &.active { + color: $session-color-white; + } } h2 { @include session-h-title; + color: $session-color-white; font-size: 22px; text-align: center; } h3 { @include session-h-title; + color: $session-color-white; font-size: 18px; padding-top: 22px; } h4 { @include session-h-title; + color: $session-color-white; font-size: 17px; text-align: center; } diff --git a/stylesheets/_session_theme_dark_left_pane.scss b/stylesheets/_session_theme_dark_left_pane.scss index 7cabb6d5d..756172a78 100644 --- a/stylesheets/_session_theme_dark_left_pane.scss +++ b/stylesheets/_session_theme_dark_left_pane.scss @@ -107,6 +107,7 @@ $session-compose-margin: 20px; &__title { flex-grow: 1; + cursor: pointer; } &__list { @@ -132,6 +133,10 @@ $session-compose-margin: 20px; padding-top: 22px; } + h4 { + text-transform: uppercase; + } + &-border-container { width: -webkit-fill-available; position: relative; diff --git a/ts/components/session/LeftPaneMessageSection.tsx b/ts/components/session/LeftPaneMessageSection.tsx index 2d2aff706..74dc49478 100644 --- a/ts/components/session/LeftPaneMessageSection.tsx +++ b/ts/components/session/LeftPaneMessageSection.tsx @@ -22,6 +22,7 @@ import { SessionIconButton, SessionIconSize, SessionIconType } from './icon'; import { SessionIdEditable } from './SessionIdEditable'; import { UserSearchDropdown } from './UserSearchDropdown'; import { validateNumber } from '../../types/PhoneNumber'; +import { LeftPaneSectionHeader } from './LeftPaneSectionHeader'; export interface Props { searchTerm: string; @@ -166,16 +167,19 @@ export class LeftPaneMessageSection extends React.Component { } public renderHeader(): JSX.Element { + const labels = []; + labels.push(window.i18n('messagesHeader')); + return ( -
-

- {window.i18n('messagesHeader')} -

- -
+ { + console.log('tabselected'); + }} + selectedTab={0} + labels={labels} + buttonLabel={window.i18n('compose')} + buttonClicked={this.handleComposeClick} + /> ); } diff --git a/ts/components/session/LeftPaneSectionHeader.tsx b/ts/components/session/LeftPaneSectionHeader.tsx new file mode 100644 index 000000000..88577ceeb --- /dev/null +++ b/ts/components/session/LeftPaneSectionHeader.tsx @@ -0,0 +1,96 @@ +import React from 'react'; +import classNames from 'classnames'; +import { SessionButton } from './SessionButton'; + +const Tab = ({ + isSelected, + label, + onSelect, + type, +}: { + isSelected: boolean; + label: string; + onSelect?: (event: number) => void; + type: number; +}) => { + const handleClick = onSelect + ? () => { + onSelect(type); + } + : undefined; + + return ( +

+ {label} +

+ ); +}; + +interface Props { + onTabSelected: any; + selectedTab: number; + labels: Array; + notificationCount?: number; + buttonLabel?: string; + buttonClicked?: any; +} + +interface State { + selectedTab: number; +} + +export class LeftPaneSectionHeader extends React.Component { + constructor(props: any) { + super(props); + this.state = { selectedTab: 0 }; + } + + public render() { + return this.renderTabs(); + } + + private renderTabs() { + const { selectedTab } = this.state; + const { labels, buttonLabel, buttonClicked } = this.props; + + const children = []; + //loop to create children + for (let i = 0; i < labels.length; i++) { + children.push( + + ); + } + + if (buttonLabel) { + children.push( + + ); + } + + //Create the parent and add the children + return
{children}
; + } + + private readonly handleTabSelect = (tabType: number): void => { + this.setState({ + selectedTab: tabType, + }); + }; +}