tailwind+react实现一个黑色自适应响应式后台管理仪表盘页面代码

代码语言:html

所属分类:响应式

代码描述:tailwind+react实现一个黑色自适应响应式后台管理仪表盘页面代码

代码标签: tailwind react 黑色 自适应 响应式 后台 管理 仪表盘

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>
<html lang="en">

<head>
   
<meta charset="UTF-8">
 
<link type="text/css" rel="stylesheet" href="//repo.bfw.wiki/bfwrepo/css/normalize.5.0.css">
   
<link type="text/css" rel="stylesheet" href="//repo.bfw.wiki/bfwrepo/css/tailwind.2.01.css">
<style>
   
@import url('https://fonts.googleapis.com/css2?family=Nunito:ital,wght@0,200;0,300;0,400;0,600;0,700;0,800;0,900;1,200;1,300;1,400;1,600;1,700;1,800;1,900&display=swap');


body
{
 
font-family: 'Nunito', sans-serif;
 
color:#676767;
 
background-color: #1e1e1e;
}

.bg-card{
 
background-color:#171717;
}
.bg-sidebar-card-top{
 
background-color: #353535;
}
.sidebar-separator-top{
 
border-bottom: 1px solid #2e2e2e;
}
.sidebar-separator-bottom{
 
border-top: 1px solid #2e2e2e;
}
.text-premium-yellow{
 
color: #f7b91c;
}
.icon-background{
 
background: #2d2d2d;
}

.tooltip-head{
background: #1d1d1d;
}
.tooltip-body{
 
background:#252525 ;
}

.search-icon{
 
top: 50%;
 
transform: translate(0, -50%);
}

.card-stack-border{
 
border-bottom: 2px solid #696969;
}
.bg-details{
 
background-color: #1e1e1e;
}

.add-component-head{
 
background-color: #181818;
 
background-image: url("//repo.bfw.wiki/bfwrepo/images/xinguang/carbon-fibre.png");
}

.sidebar-item-selected{
 
color: white;
 
border-right: 2px solid white;
}
.sidebar-item{
 
border-right: 2px solid transparent;
}
.sidebar-item:hover {
 
color:#a1a0a0;
}
</style>
</head>

<body>
   
<div id="root"></div>
<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/react.production.17.1.js"></script>
<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/react-dom.production.17.1.js"></script>
<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/prop-types.min.js"></script>
<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/react-spring-web.js"></script>
<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/Recharts.min.js"></script>
   
<script type="module">
        import clsx from "//repo.bfw.wiki/bfwrepo/js/module/clsx/clsx.js";
const { useState } = React;
const { useSpring, animated, config } = ReactSpring;
const { LineChart,
  Line,
  XAxis,
  YAxis,
  CartesianGrid,
  Tooltip,
  ResponsiveContainer } = Recharts;

const map = (value, sMin, sMax, dMin, dMax) => {
  return dMin + (value - sMin) / (sMax - sMin) * (dMax - dMin);
};
const pi = Math.PI;
const tau = 2 * pi;

const employeeData = [
{
  id: 1,
  name: 'Esther Howard',
  position: "Sale's manager USA",
  transactions: 3490,
  rise: true,
  tasksCompleted: 3,
  imgId: 0 },


{
  id: 2,
  name: 'Eleanor Pena',
  position: "Sale's manager Europe",
  transactions: 590,
  rise: false,
  tasksCompleted: 5,
  imgId: 2 },


{
  id: 3,
  name: 'Robert Fox',
  position: "Sale's manager Asia",
  transactions: 2600,
  rise: true,
  tasksCompleted: 1,
  imgId: 3 }];



const Countrydata = [
{ name: 'USA', rise: true, value: 21942.83, id: 1 },
{ name: 'Ireland', rise: false, value: 19710.0, id: 2 },
{ name: 'Ukraine', rise: false, value: 12320.3, id: 3 },
{ name: 'Sweden', rise: true, value: 9725.0, id: 4 }];

const segmentationData = [
{ c1: 'Not Specified', c2: '800', c3: '#363636', color: '#535353' },
{ c1: 'Male', c2: '441', c3: '#818bb1', color: '#595f77' },
{ c1: 'Female', c2: '233', c3: '#2c365d', color: '#232942' },
{ c1: 'Other', c2: '126', c3: '#334ed8', color: '#2c3051' }];


const sidebarItems = [
[
{ id: '0', title: 'Dashboard', notifications: false },
{ id: '1', title: 'Overview', notifications: false },
{ id: '2', title: 'Chat', notifications: 6 },
{ id: '3', title: 'Team', notifications: false }],

[
{ id: '4', title: 'Tasks', notifications: false },
{ id: '5', title: 'Reports', notifications: false },
{ id: '6', title: 'Settings', notifications: false }]];



const graphData = [
'Nov',
'Dec',
'Jan',
'Feb',
'Mar',
'Apr',
'May',
'June',
'July'].
map(i => {
  const revenue = 500 + Math.random() * 2000;
  const expectedRevenue = Math.max(revenue + (Math.random() - 0.5) * 2000, 0);
  return {
    name: i,
    revenue,
    expectedRevenue,
    sales: Math.floor(Math.random() * 500) };

});

const App = () => {
  const [showSidebar, onSetShowSidebar] = useState(false);
  return /*#__PURE__*/(
    React.createElement("div", { className: "flex" }, /*#__PURE__*/
    React.createElement(Sidebar, {
      onSidebarHide: () => {
        onSetShowSidebar(false);
      },
      showSidebar: showSidebar }), /*#__PURE__*/

    React.createElement(Content, {
      onSidebarHide: () => {
        onSetShowSidebar(true);
      } })));



};

function Sidebar({ onSidebarHide, showSidebar }) {
  const [selected, setSelected] = useState('0');
  const { dashOffset, indicatorWidth, precentage } = useSpring({
    dashOffset: 26.015,
    indicatorWidth: 70,
    precentage: 77,
    from: { dashOffset: 113.113, indicatorWidth: 0, precentage: 0 },
    config: config.molasses });

  return /*#__PURE__*/(
    React.createElement("div", {
      className: clsx(
      'fixed inset-y-0 left-0 bg-card w-full sm:w-20 xl:w-60 sm:flex flex-col z-10',
      showSidebar ? 'flex' : 'hidden') }, /*#__PURE__*/


    React.createElement("div", { className: "flex-shrink-0 overflow-hidden p-2" }, /*#__PURE__*/
    React.createElement("div", { className: "flex items-center h-full sm:justify-center xl:justify-start p-2 sidebar-separator-top" }, /*#__PURE__*/
    React.createElement(IconButton, { icon: "res-react-dash-logo", className: "w-10 h-10" }), /*#__PURE__*/
    React.createElement("div", { className: "block sm:hidden xl:block ml-2 font-bold text-xl text-white" }, "React"), /*#__PURE__*/


    React.createElement("div", { className: "flex-grow sm:hidden xl:block" }), /*#__PURE__*/
    React.createElement(IconButton, {
      icon: "res-react-dash-sidebar-close",
      className: "block sm:hidden",
      onClick: onSidebarHide }))), /*#__PURE__*/



    React.createElement("div", { className: "flex-grow overflow-x-hidden overflow-y-auto flex flex-col" }, /*#__PURE__*/
    React.createElement("div", { className: "w-full p-3 h-24 sm:h-20 xl:h-24 hidden sm:block flex-shrink-0" }, /*#__PURE__*/
    React.createElement("div", { className: "bg-sidebar-card-top rounded-xl w-full h-full flex items-center justify-start sm:justify-center xl:justify-start px-3 sm:px-0 xl:px-3" }, /*#__PURE__*/
    React.createElement(Icon, { path: "res-react-dash-sidebar-card", className: "w-9 h-9 " }), /*#__PURE__*/
    React.createElement("div", { className: "block sm:hidden xl:block ml-3" }, /*#__PURE__*/
    React.createElement("div", { className: "text-sm font-bold text-white" }, "Sales House"), /*#__PURE__*/
    React.createElement("div", { className: "text-sm" }, "General Item")), /*#__PURE__*/

    React.createElement("div", { className: "block sm:hidden xl:block flex-grow" }), /*#__PURE__*/
    React.createElement(Icon, {
      path: "res-react-dash-sidebar-card-select",
      className: "block sm:hidden xl:block w-5 h-5" }))),



    sidebarItems[0].map((i) => /*#__PURE__*/
    React.createElement(MenuItem, {
      key: i.id,
      item: i,
      onClick: setSelected,
      selected: selected })), /*#__PURE__*/


    React.createElement("div", { className: "mt-8 mb-0 font-bold px-3 block sm:hidden xl:block" }, "SHORTCUTS"),


    sidebarItems[1].map((i) => /*#__PURE__*/
    React.createElement(MenuItem, {
      key: i.id,
      item: i,
      onClick: setSelected,
      selected: selected })), /*#__PURE__*/


    React.createElement("div", { className: "flex-grow" }), /*#__PURE__*/
    React.createElement("div", { className: "w-full p-3 h-28 hidden sm:block sm:h-20 xl:h-32" }, /*#__PURE__*/
    React.createElement("div", {
      className: "rounded-xl w-full h-full px-3 sm:px-0 xl:px-3 overflow-hidden",
      style: {
        backgroundImage: "url('//repo.bfw.wiki/bfwrepo/images/xinguang/res-react-dash-usage-card.svg')" } }, /*#__PURE__*/


    React.createElement("div", { className: "block sm:hidden xl:block pt-3" }, /*#__PURE__*/
    React.createElement("div", { className: "font-bold text-gray-300 text-sm" }, "Used Space"), /*#__PURE__*/
    React.createElement("div", { className: "text-gray-500 text-xs" }, "Admin updated 09:12 am November 08,2020"), /*#__PURE__*/


    React.createElement(animated.div, { className: "text-right text-gray-400 text-xs" },
    precentage.interpolate(i => `${Math.round(i)}%`)), /*#__PURE__*/

    React.createElement("div", { className: "w-full text-gray-300" }, /*#__PURE__*/
    React.createElement("svg", {
      viewBox: "0 0 100 11",
      fill: "none",
      xmlns: "http://www.w3.org/2000/svg" }, /*#__PURE__*/

    React.createElement("line", {
      x1: "5",
      y1: "5.25",
      x2: "95",
      y2: "5.25",
      stroke: "#3C3C3C",
      strokeWidth: "5",
      strokeLinecap: "round" }), /*#__PURE__*/

    React.createElement(animated.line, {
      x1: "5",
      y1: "5.25",
      x2: indicatorWidth,
      y2: "5.25",
      stroke: "currentColor",
      strokeWidth: "5",
      strokeLinecap: "round" })))), /*#__PURE__*/





    React.createElement("div", { className: "hidden sm:block xl:hidden " }, /*#__PURE__*/
    React.createElement("svg", {
      width: "56",
      height: "56",
      viewBox: "0 0 56 56",
      fill: "none",
      xmlns: "http://www.w3.org/2000/svg" }, /*#__PURE__*/

    React.createElement("rect", { width: "56", height: "56", fill: "#2C2C2D" }), /*#__PURE__*/
    React.createElement("path", {
      d: "M 28 28 m 0, -18 a 18 18 0 0 1 0 36 a 18 18 0 0 1 0 -36",
      stroke: "#3C3C3C",
      strokeWidth: "6" }), /*#__PURE__*/

    React.createElement(animated.path, {
      d: "M 28 28 m 0, -18 a 18 18 0 0 1 0 36 a 18 18 0 0 1 0 -36",
      stroke: "#fff",
      strokeLinecap: "round",
      strokeDasharray: "113.113",
      strokeDashoffset: dashOffset,
      strokeWidth: "6" })))))), /*#__PURE__*/







    React.createElement("div", { className: "flex-shrink-0 overflow-hidden p-2" }, /*#__PURE__*/
    React.createElement("div", { className: "flex items-center h-full sm:justify-center xl:justify-start p-2 sidebar-separator-bottom" }, /*#__PURE__*/
    React.createElement(Image, { path: "mock_faces_8", className: "w-10 h-10" }), /*#__PURE__*/
    React.createElement("div", { className: "block sm:hidden xl:block ml-2 font-bold " }, "Jerry Wilson"), /*#__PURE__*/


    React.createElement("div", { className: "flex-grow block sm:hidden xl:block" }), /*#__PURE__*/
    React.createElement(Icon, {
      path: "res-react-dash-options",
      className: "block sm:hidden xl:block w-3 h-3" })))));





}
function MenuItem({ item: { id, title, notifications }, onClick, selected }) {
  return /*#__PURE__*/(
    React.createElement("div", {
      className: clsx(
      'w-full mt-6 flex items-center px-3 sm:px-0 xl:px-3 justify-start sm:justify-center xl:justify-start sm:mt-6 xl:mt-3 cursor-pointer',
      selected === id ? 'sidebar-item-selected' : 'sidebar-item'),

      onClick: () => onClick(id) }, /*#__PURE__*/

    React.createElement(SidebarIcons, { id: id }), /*#__PURE__*/
    React.createElement("div", { className: "block sm:hidden xl:block ml-2" }, title), /*#__PURE__*/
    React.createElement("div", { className: "block sm:hidden xl:block flex-grow" }),
    notifications && /*#__PURE__*/
    React.createElement("div", { className: "flex sm:hidden xl:flex bg-pink-600  w-5 h-5 flex items-center justify-center rounded-full mr-2" }, /*#__PURE__*/
    React.createElement("div", { className: "text-white text-sm" }, notifications))));




}
function Content({ onSidebarHide }) {
  return /*#__PURE__*/(
    React.createElement("div", { className: "flex w-full" }, /*#__PURE__*/
    React.createElement("div", { className: "w-full h-screen hidden sm:block sm:w-20 xl:w-60 flex-shrink-0" }, "."), /*#__PURE__*/


    React.createElement("div", { className: " h-screen flex-grow overflow-x-hidden overflow-auto flex flex-wrap content-start p-2" }, /*#__PURE__*/
    React.createElement("div", { className: "w-full sm:flex p-2 items-end" }, /*#__PURE__*/
    React.createElement("div", { className: "sm:flex-grow flex justify-between" }, /*#__PURE__*/
    React.createElement("div", { className: "" }, /*#__PURE__*/
    React.createElement("div", { className: "flex items-center" }, /*#__PURE__*/
    React.createElement("div", { className: "text-3xl font-bold text-white" }, "Hello David"), /*#__PURE__*/
    React.createElement("div", { className: "flex items-center p-2 bg-card ml-2 rounded-xl" }, /*#__PURE__*/
    React.createElement(Icon, { path: "res-react-dash-premium-star" }), /*#__PURE__*/

    React.createElement("div", { className: "ml-2 font-bold text-premium-yellow" }, "PREMIUM"))), /*#__PURE__*/




    React.createElement("div", { className: "flex items-center" }, /*#__PURE__*/
    React.createElement(Icon, {
      path: "res-react-dash-date-indicator",
      className: "w-3 h-3" }), /*#__PURE__*/

    React.createElement("div", { className: "ml-2" }, "October 26"))), /*#__PURE__*/


    React.createElement(IconButton, {
      icon: "res-react-dash-sidebar-open",
      className: "block sm:hidden",
      onClick: onSidebarHide })), /*#__PURE__*/


    React.createElement("div", { className: "w-full sm:w-56 mt-4 sm:mt-0 relative" }, /*#__PURE__*/
    React.createElement(Icon, {
      path: "res-react-dash-search",
      className: "w-5 h-5 search-icon left-3 absolute" }), /*#__PURE__*/

    React.createElement("form", { action: "#", method: "POST" }, /*#__PURE__*/
    React.createElement("input", {
      type: "text",
      name: "company_website",
      id: "company_website",
      className: "pl-12 py-2 pr-2 block w-full rounded-lg border-gray-300 bg-card",
      placeholder: "search" })))),




    employeeData.map(
    ({
      id,
      name,
      position,
      transactions,
      rise,
      tasksCompleted,
      imgId }) => /*#__PURE__*/

    React.createElement(NameCard, {
      key: id,
      id: id,
      name: name,
      position: position,
      transactionAmount: transactions,
      rise: rise,
      tasksCompleted: tasksCompleted,
      imgId: imgId })), /*#__PURE__*/




    React.createElement("div", { className: "w-full p-2 lg:w-2/3" }, /*#__PURE__*/
    React.createElement("div", { classN.........完整代码请登录后点击上方下载按钮下载查看

网友评论0