Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
@barokatu/react-chrome-tabs
Advanced tools
yarn add @sinm/react-chrome-tabs
import { Tabs, TabProperties } from "@sinm/react-chrome-tabs";
import '@sinm/react-chrome-tabs/css/chrome-tabs.css';
const [tabs, setTabs] = useState<TabProperties[]>([
{ id: "abc", favicon: fb, title: "测试", active: true },
]);
<Tabs
onTabClose={close}
onTabReorder={reorder}
onTabActive={active}
tabs={tabs}
/>
import React, { useEffect } from "react";
import { useState } from "react";
import { Tabs, TabProperties } from "@sinm/react-chrome-tabs";
import '@sinm/react-chrome-tabs/css/chrome-tabs.css';
import fb from "./images/facebook-favicon.ico";
import google from "./images/google-favicon.ico";
let id = 1;
function App() {
const [tabs, setTabs] = useState<TabProperties[]>([
{ id: "abc", favicon: fb, title: "测试", active: true },
]);
const addTab = () => {
id++;
setTabs([
...tabs,
{
id: `tab-id-${id}`,
title: `New Tabs ${id}`,
favicon: tabs.length % 2 ? fb : google,
},
]);
};
const active = (id: string) => {
setTabs(tabs.map((tab) => ({ ...tab, active: id === tab.id })));
};
const close = (id: string) => {
setTabs(tabs.filter((tab) => tab.id !== id));
};
const reorder = (tabId: string, fromIndex: number, toIndex: number) => {
const beforeTab = tabs.find(tab => tab.id === tabId);
if (!beforeTab) {
return;
}
let newTabs = tabs.filter(tab => tab.id !== tabId);
newTabs.splice(toIndex, 0, beforeTab);
setTabs(newTabs);
};
const closeAll = () => setTabs([]);
return (
<div>
<Tabs
onTabClose={close}
onTabReorder={reorder}
onTabActive={active}
tabs={tabs}
></Tabs>
<button onClick={addTab}>Add Tab</button>
<button onClick={closeAll}>Close All</button>
</div>
);
}
More Examples see
name | type | description |
---|---|---|
tabs | TabProperties | tabs to render |
onTabActive | Function | when tab active |
onTabClose | Function | when tab close |
onTabReorder | Function | when tab drag to reorder |
onContextMenu | Function | when trigger context menu event |
export interface TabProperties {
id: string;
title: string;
active?: boolean;
// favicon background image
favicon?: boolean | string;
// favicon class
faviconClass?: string;
}
git clone https://github.com/pansinm/react-chrome-tabs.git
cd react-chrome-tabs
yarn start
# visit http://localhost:8080/
FAQs
React Chrome-style tabs
The npm package @barokatu/react-chrome-tabs receives a total of 4 weekly downloads. As such, @barokatu/react-chrome-tabs popularity was classified as not popular.
We found that @barokatu/react-chrome-tabs demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.