Better print style + base tabs

This commit is contained in:
2020-04-21 14:10:50 +02:00
parent 6e0ccd5575
commit 642b555b3d
17 changed files with 287 additions and 107 deletions

View File

@ -20,7 +20,7 @@ const App: FunctionalComponent = () => {
return (
<div id="app">
<Header />
<Header class="noPrint" />
<Router onChange={handleRoute}>
<Route path="/" component={Home} />
<Route path="/p/:projectId" component={Project} />

View File

@ -2,9 +2,13 @@ import { FunctionalComponent, h } from "preact";
import { Link } from "preact-router/match";
import * as style from "./style.css";
const Header: FunctionalComponent = () => {
export interface HeaderProps {
class?: string
}
const Header: FunctionalComponent<HeaderProps> = ({ ...props}) => {
return (
<div class="container">
<div class={`container ${props.class ? props.class : ''}`}>
<div class="columns">
<div class="column">
<nav class="navbar" role="navigation" aria-label="main navigation">

View File

@ -0,0 +1,50 @@
import { FunctionalComponent, h, ComponentChild } from "preact";
import * as style from "./style.css";
import { useState } from "preact/hooks";
export interface TabItem {
label: string
icon?: string
render: () => ComponentChild
}
export interface TabsProps {
class?: string
items: TabItem[]
}
const Tabs: FunctionalComponent<TabsProps> = ({ items, ...props }) => {
const [ selectedTabIndex, setSelectedTabIndex ] = useState(0);
const onTabClick = (tabIndex: number) => {
setSelectedTabIndex(tabIndex);
};
const selectedTab = items[selectedTabIndex];
return (
<div class={`${style.tabs} ${props.class}`}>
<div class="tabs">
<ul class={`noPrint`}>
{
items.map((tabItem, tabIndex) => (
<li key={`tab-${tabIndex}`}
onClick={onTabClick.bind(null, tabIndex)}
class={`${selectedTabIndex === tabIndex ? 'is-active' : ''}`}>
<a>
<span class="icon is-small">{tabItem.icon}</span>
{tabItem.label}
</a>
</li>
))
}
</ul>
</div>
<div class={style.tabContent}>
{ selectedTab.render() }
</div>
</div>
);
};
export default Tabs;

View File

@ -0,0 +1,8 @@
.tabs {
display: inherit;
}
.tabContent {
padding-top: 1em;
max-width: 100%;
}

3
src/components/tabs/style.css.d.ts vendored Normal file
View File

@ -0,0 +1,3 @@
// This file is automatically generated from your CSS. Any edits will be overwritten.
export const tabs: string;
export const tabContent: string;