-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'responsive' into storybook
- Loading branch information
Showing
27 changed files
with
256 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
const API_BASE_URL = 'http://localhost:8000/api'; | ||
|
||
export { API_BASE_URL }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
#root { | ||
max-width: 1280px; | ||
margin: 0 auto; | ||
padding: 2rem; | ||
text-align: center; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import React, { useEffect, useState } from 'react'; | ||
import { Link, useLocation } from 'react-router-dom'; | ||
import { API_BASE_URL } from '../APIConfig'; | ||
|
||
export const Breadcrumbs = () => { | ||
const location = useLocation(); | ||
const [breadcrumbLabels, setBreadcrumbLabels] = useState({}); | ||
const pathnames = location.pathname.split('/').filter(x => x); | ||
|
||
const fetchModelInfo = async () => { | ||
const response = await fetch(API_BASE_URL + `/model-info`); | ||
const modelInfo = await response.json(); | ||
return modelInfo.title; | ||
}; | ||
|
||
// Function to fetch view names | ||
const fetchViewName = async (idx) => { | ||
const response = await fetch(API_BASE_URL + `/views`); | ||
|
||
const views = await response.json(); | ||
const view = views.find(v => v.idx.toString() === idx); | ||
return view ? view.name : idx; | ||
}; | ||
|
||
// Function to fetch object names | ||
const fetchObjectName = async (uuid) => { | ||
const response = await fetch(API_BASE_URL + `/objects/${uuid}`); | ||
const object = await response.json(); | ||
return object.name; | ||
}; | ||
|
||
useEffect(() => { | ||
const updateLabels = async () => { | ||
const title = await fetchModelInfo(); | ||
const labels = { '/': title }; | ||
|
||
for (let i = 0; i < pathnames.length; i++) { | ||
const to = `/${pathnames.slice(0, i + 1).join('/')}`; | ||
|
||
if (pathnames[i] === 'views') { | ||
labels[to] = 'Views'; | ||
} else if (i === 1 && pathnames[0] === 'views') { | ||
labels[to] = await fetchViewName(pathnames[i]); | ||
} else if (i === 2 && pathnames[0] === 'views') { | ||
labels[to] = await fetchObjectName(pathnames[i]); | ||
} else { | ||
labels[to] = pathnames[i]; | ||
} | ||
} | ||
console.log(labels); | ||
|
||
setBreadcrumbLabels(labels); | ||
}; | ||
|
||
updateLabels(); | ||
}, [location]); | ||
|
||
const visible_pathnames = [breadcrumbLabels['/'], ...location.pathname.split('/').filter(x => x)]; | ||
|
||
return ( | ||
<nav aria-label="breadcrumb" className="flex items-center"> | ||
<ol className="flex items-center"> | ||
<li className="flex items-center dark:text-gray-200"> | ||
<span>{breadcrumbLabels['/']}</span> | ||
<span className="mx-2">/</span> | ||
</li> | ||
{visible_pathnames.slice(1).map((value, index) => { | ||
const last = index === visible_pathnames.length - 2; | ||
const to = `/${visible_pathnames.slice(1, index + 2).join('/')}`; | ||
const label = breadcrumbLabels[to] || value; | ||
|
||
return ( | ||
<li className="flex items-center" key={to}> | ||
{!last && <Link to={to}>{label}</Link>} | ||
{last && <span className='dark:text-gray-200' >{label}</span>} | ||
{!last && <span className="mx-2">/</span>} | ||
</li> | ||
); | ||
})} | ||
</ol> | ||
</nav> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import React from 'react'; | ||
|
||
export const Button = ({ theme, children, ...props }) => { | ||
return ( | ||
<a href="#" {...props} className="rounded-md mx-1 bg-blue-800 px-2.5 py-1.5 text-sm font-semibold text-white shadow-sm hover:bg-blue-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 "> | ||
{children} | ||
</a> | ||
); | ||
}; |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import React, { useState, useEffect } from 'react'; | ||
import { Button } from './Button'; | ||
|
||
export const ThemeSwitcher = () => { | ||
const [theme, setTheme] = useState('light'); // default theme is light | ||
|
||
useEffect(() => { | ||
if (theme === 'dark') { | ||
document.documentElement.classList.add('dark'); | ||
} else { | ||
document.documentElement.classList.remove('dark'); | ||
} | ||
}, [theme]); | ||
|
||
const switchTheme = (newTheme) => { | ||
setTheme(newTheme); | ||
}; | ||
|
||
return ( | ||
<div> | ||
{theme !== 'light' && <Button onClick={() => switchTheme('light')}>Light</Button>} | ||
{theme !== 'dark' && <Button onClick={() => switchTheme('dark')}>Dark</Button>} | ||
{theme !== 'auto' && <Button onClick={() => switchTheme('auto')}>Auto</Button>} | ||
</div> | ||
); | ||
}; |
Oops, something went wrong.