From 5ebf4c27c539d535f768ec9a215d87807a783543 Mon Sep 17 00:00:00 2001 From: Dmitry Vdovin Date: Mon, 27 Feb 2017 02:29:40 +0200 Subject: [PATCH] [#787] Rework profile header Changed class names according to the new BEM naming convention. Added page-head__title-wrapper and page-head__subtitle classes. --- src/components/page.js | 36 ++++++++++----- src/components/page/captions.js | 44 +++++++++++++++++++ src/less/blocks/icon.less | 4 ++ .../blocks/{page_head.less => page-head.less} | 20 ++++++--- src/less/styles.less | 2 +- src/pages/base/settings.js | 13 ++---- src/pages/base/tag.js | 12 ++--- src/pages/base/user.js | 12 +---- 8 files changed, 100 insertions(+), 43 deletions(-) create mode 100644 src/components/page/captions.js rename src/less/blocks/{page_head.less => page-head.less} (86%) diff --git a/src/components/page.js b/src/components/page.js index 2aa9cc57..8d409a44 100644 --- a/src/components/page.js +++ b/src/components/page.js @@ -17,6 +17,8 @@ */ import React from 'react'; import classNames from 'classnames'; +import { isString } from 'lodash'; + const Page = ({ children, className = '' }) => (
@@ -24,18 +26,30 @@ const Page = ({ children, className = '' }) => (
); -const PageCaption = ({ children, icon }) => ( -
-

- {children} -

- {icon && -
- {icon} +const PageCaption = ({ children, iconLeft, iconRight }) => { + let title = children; + if (isString(children)) { + title =

{children}

; + } + + return ( +
+ {iconLeft && +
+ {iconLeft} +
+ } +
+ {title}
- } -
-); + {iconRight && +
+ {iconRight} +
+ } +
+ ); +}; const PageHero = ({ children, url }) => (
diff --git a/src/components/page/captions.js b/src/components/page/captions.js new file mode 100644 index 00000000..438cefaa --- /dev/null +++ b/src/components/page/captions.js @@ -0,0 +1,44 @@ +/* + This file is a part of libertysoil.org website + Copyright (C) 2016 Loki Education (Social Enterprise) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +import React from 'react'; + +import { getName } from '../../utils/user'; +import Avatar from '../user/avatar'; +import Icon from '../icon'; +import { + PageCaption +} from '../page'; + + +export const UserCaption = ({ user }) => { + if (!user) { + return ( + + ); + } + + return ( + } + iconRight={} + > +

{user.get('username')}

+

{getName(user)}

+
+ ); +}; diff --git a/src/less/blocks/icon.less b/src/less/blocks/icon.less index 5328382d..dde920c5 100644 --- a/src/less/blocks/icon.less +++ b/src/less/blocks/icon.less @@ -16,6 +16,10 @@ &--dark_green { background: @color__dark_green; } + + &--khaki { + background: #D4D366; + } } &-midi.icon-outline { diff --git a/src/less/blocks/page_head.less b/src/less/blocks/page-head.less similarity index 86% rename from src/less/blocks/page_head.less rename to src/less/blocks/page-head.less index 4b6387f3..7f80bc18 100644 --- a/src/less/blocks/page_head.less +++ b/src/less/blocks/page-head.less @@ -17,20 +17,29 @@ */ // A block representing a header on a page of a certain entity (user, tag, whatever). -.page_head { +.page-head { @size: 60px; min-height: @size; display: flex; - background-color: white; align-items: center; - justify-content: space-between; + margin-bottom: 2px; + background-color: white; - &__title { + &__title-wrapper { display: block; padding-left: @space; - color: @color__text; + flex-grow: 1; + } + + &__title { font-size: 20px; + color: #0077B5; + } + + &__subtitle { + font-size: 12px; + color: @color__dark_gray; } &__icon { @@ -39,6 +48,7 @@ height: @size; align-items: center; justify-content: space-around; + background-color: #FAFAFA; //background-color: #f3f3f3; // TODO: Choose background color depending on the type of an item. } } diff --git a/src/less/styles.less b/src/less/styles.less index 7fde9572..61943b2f 100644 --- a/src/less/styles.less +++ b/src/less/styles.less @@ -53,7 +53,7 @@ @import 'blocks/micon'; @import 'blocks/page'; -@import 'blocks/page_head'; +@import 'blocks/page-head'; @import 'blocks/header'; @import 'blocks/logo'; @import 'blocks/footer'; diff --git a/src/pages/base/settings.js b/src/pages/base/settings.js index e72acacc..24ce42e8 100644 --- a/src/pages/base/settings.js +++ b/src/pages/base/settings.js @@ -42,9 +42,8 @@ import Sidebar from '../../components/sidebar'; import Messages from '../../components/messages'; import SidebarAlt from '../../components/sidebarAlt'; import PageContentLink from '../../components/page-content-link'; +import { UserCaption } from '../../components/page/captions'; -import Avatar from '../../components/user/avatar'; -import { getName } from '../../utils/user'; class BaseSettingsPage extends React.Component { static displayName = 'BaseSettingsPage'; @@ -117,16 +116,10 @@ class BaseSettingsPage extends React.Component {
+
+
-
-

- {getName(user)} -

-
- -
-
{children}
diff --git a/src/pages/base/tag.js b/src/pages/base/tag.js index 7868d860..ba71d212 100644 --- a/src/pages/base/tag.js +++ b/src/pages/base/tag.js @@ -23,6 +23,7 @@ import { PageMain, PageHero, PageBody, + PageCaption, PageContent } from '../../components/page'; import Header from '../../components/header'; @@ -64,14 +65,13 @@ function getPageCaption(type, name) { } return ( -
-

+ } + > +

{caption}

-
- -
-

+ ); } diff --git a/src/pages/base/user.js b/src/pages/base/user.js index 1a803be7..8c950bec 100644 --- a/src/pages/base/user.js +++ b/src/pages/base/user.js @@ -33,7 +33,6 @@ import { PageBody, PageContent } from '../../components/page'; -import Avatar from '../../components/user/avatar'; import Breadcrumbs from '../../components/breadcrumbs/breadcrumbs'; import Header from '../../components/header'; import HeaderLogo from '../../components/header-logo'; @@ -43,7 +42,7 @@ import ProfileHeader from '../../components/profile'; import Sidebar from '../../components/sidebar'; import SidebarAlt from '../../components/sidebarAlt'; import User from '../../components/user'; -import { getName } from '../../utils/user'; +import { UserCaption } from '../../components/page/captions'; // FIXME: These links won't hide/show properly if following/unfollowing is performed directly on the page. // Something is wrong with the redux state. @@ -96,14 +95,7 @@ const BaseUserPage = (props) => { -
-

- {getName(user)} -

-
- -
-
+