Skip to content
Snippets Groups Projects
Commit 09202737 authored by Loïc Correnson's avatar Loïc Correnson
Browse files

[dome] updated tabs styling

parent 763e1262
No related branches found
No related tags found
No related merge requests found
...@@ -6,11 +6,11 @@ ...@@ -6,11 +6,11 @@
.dome-xTabsBar { .dome-xTabsBar {
flex: 0 1 auto ; flex: 0 1 auto ;
flex-flow: row wrap ;
position: relative ; position: relative ;
height: 20px ; height: 20px ;
width: calc( 100% + 1px ); /* hides last border */ width: calc( 100% + 1px ); /* hides last border */
display: flex ; display: flex ;
flex: row wrap ;
border-width: 1px ; border-width: 1px ;
border-bottom-style: solid ; border-bottom-style: solid ;
} }
...@@ -25,59 +25,57 @@ ...@@ -25,59 +25,57 @@
/* Tab Item */ /* Tab Item */
.dome-xTab { .dome-xTab {
flex: 1 1 150px ; display: flex;
position: relative ; position: relative ;
font-size: 10px ; font-size: 10px ;
text-align: center ; text-align: center ;
padding: 4px 20px 4px 20px ; padding: 4px ;
border-color: inherit ; border-color: inherit ;
border-width: 1px ; border-width: 1px ;
border-top-style: none ; border-top-style: none ;
border-bottom-style: none ; border-bottom-style: none ;
border-left-style: none ; border-left-style: none ;
border-right-style: solid ; border-right-style: solid ;
height: 100%;
} }
.dome-xTab.dome-inactive:hover { .dome-xTab.dome-active {
background: var(--background-disabled-hover) ; flex: 1 1 auto ;
background: var(--background-intense);
} }
.dome-xTab.dome-inactive { .dome-xTab.dome-inactive {
flex: 0 1 150px ;
color: var(--text-discrete) ; color: var(--text-discrete) ;
border-color: var(--border) ; border-color: var(--border) ;
background: var(--background-disabled) ; background: var(--background-profound);
} }
/* Closing Tab button */ .dome-xTab.dome-inactive:hover {
background: var(--background-profound-hover);
}
.dome-xTab-closing { .dome-xTab-icon {
display: inline ; flex: 0 0 12px;
border-radius: 4px ; border-radius: 4px ;
position: absolute ;
width: 12px ;
height: 12px ;
padding: 2px ;
top: 2px ;
opacity: 0 ;
transition: opacity .1s linear 0.1s , background .1s linear 0.1s ;
} }
.dome-platform-darwin .dome-xTab-closing { .dome-xTab-icon:hover {
right: initial ; background: var(--background-button-hover);
left: 5px ;
} }
.dome-xTab-closing { .dome-xTab-icon.dome-inactive {
right: 5px ; fill: var()
left: initial ;
} }
.dome-xTab-closing:hover { .dome-xTab-label {
background: var(--background-button-hover); flex: 0 1 auto;
overflow: hidden;
text-overflow: ellipsis;
} }
.dome-xTab:hover .dome-xTab-closing { .dome-xTab-filler {
opacity: 1 ; flex: 1 1 0px;
} }
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
import React from 'react'; import React from 'react';
import { Icon } from 'dome/controls/icons'; import { Icon } from 'dome/controls/icons';
import { classes } from 'dome/misc/utils';
import './style.css'; import './style.css';
...@@ -55,48 +56,76 @@ export function TabsBar(props: TabsBarProps): JSX.Element { ...@@ -55,48 +56,76 @@ export function TabsBar(props: TabsBarProps): JSX.Element {
// --- Single Tab // --- Single Tab
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
export interface TabProps<A> { export interface TabIcon {
/** Tab's identifier. */ icon: string;
value: A; title?: string;
display?: boolean;
enabled?: boolean;
onClick?: () => void;
}
export interface TabProps {
/** Tab's label icon. */
icon?: string;
/** Tab's label. */ /** Tab's label. */
label?: string; label?: string;
/** Tab's tooltip text. */ /** Tab's tooltip text. */
title?: string; title?: string;
/** Close tab's tooltip text. */
closing?: string;
/** Currently selected tab. */ /** Currently selected tab. */
selection?: A; selected: boolean;
headIcons?: TabIcon[];
tailIcons?: TabIcon[];
/** Selection callback. */ /** Selection callback. */
onSelection?: (value: A) => void; onSelection: () => void;
/** Closing callback. */
onClose?: (value: A) => void;
} }
/** Tab Selector. */ /** Tab Selector. */
export function Tab<A>(props: TabProps<A>): JSX.Element { export function Tab(props: TabProps): JSX.Element {
const { value, selection, onSelection, onClose } = props; const { icon, selected, onSelection } = props;
const selected = value === selection;
// --- Tab Rendering // --- Tab Rendering
const onSelect = onSelection && (() => onSelection(value)); const { headIcons = [], tailIcons = [] } = props;
const onClosed = onClose && (() => onClose(value)); const makeIcon = (icn: TabIcon): JSX.Element | null => {
const closing = onClose ? ( const { icon, title, display = true, enabled = true } = icn;
<Icon if (!display) return null;
className="dome-xTab-closing" const className = classes(
title={props.closing || 'Close Tab'} 'dome-xTab-icon',
id="CROSS" !enabled && 'dome-control-disabled'
onClick={onClosed} );
/> return (
) : undefined; <Icon key={icon}
const classes = `dome-xTab${selected ? ' dome-active' : ' dome-inactive'}`; className={className}
title={title}
id={icon} size={10} offset={1}
onClick={enabled ? icn.onClick : undefined}
/>
);
};
const labelIcon = icon ? (
<Icon key='icon'
className='dome-xTab-icon'
id={icon} size={10} offset={1} />
) : null;
const header = selected ? headIcons.map(makeIcon) : null;
const trailer = selected ? tailIcons.map(makeIcon) : null;
const classNames = classes(
'dome-xTab',
selected ? 'dome-active' : 'dome-inactive'
);
return ( return (
<label <div
className={classes} className={classNames}
title={props.title} title={props.title}
onClick={onSelect} onClick={onSelection}
> >
{props.label} {header}
{closing} <div className='dome-xTab-filler' />
</label> {labelIcon}
<label key='name' className='dome-xTab-label'>
{props.label}
</label>
<div className='dome-xTab-filler' />
{trailer}
</div>
); );
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment