Skip to content

Commit

Permalink
tv documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
bipoza committed Dec 13, 2022
1 parent 2d82205 commit b5a9d81
Show file tree
Hide file tree
Showing 8 changed files with 269 additions and 125 deletions.
3 changes: 3 additions & 0 deletions nahieran-js-doc/src/App.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.border-radius {
border-radius: 10px;
}
33 changes: 26 additions & 7 deletions nahieran-js-doc/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
import DocCard from './Components/DocCard';
import { TV_DOCS } from './Docs/tv';
import { GETTING_STARTED } from './Docs/general';

import './App.css';

function App() {
const darkTheme = createTheme({
Expand All @@ -24,9 +24,24 @@ function App() {
}
},
});

const lightTheme = createTheme({
palette: {
mode: 'light',
// primary: blueGrey,
primary: { main: "#343C46" },
text: {
primary: "#343C46",
secondary: "#343C46",
},
divider: "#343C46",
background: {
// default: "#222831",
// paper: "#1B2430"
}
},
});
return (
<ThemeProvider theme={darkTheme}>
<ThemeProvider theme={lightTheme}>
<CssBaseline />
<Container fixed>
<MenuAppBar />
Expand All @@ -42,10 +57,14 @@ function App() {
TV
</Typography>
{
TV_DOCS.map(doc => <DocCard
title={doc.title}
markdown={doc.description}
demoFunction={doc.demoFunction} />)
TV_DOCS.map(doc => <Box sx={{ marginBottom: 3 }}>
<DocCard
title={doc.title}
markdown={doc.description}
actionFunction={doc.actionFunction}
actionParam={doc.actionParam}
/>
</Box>)
}
</Box>

Expand Down
207 changes: 118 additions & 89 deletions nahieran-js-doc/src/Components/AppBar.jsx
Original file line number Diff line number Diff line change
@@ -1,93 +1,122 @@
import * as React from 'react';
import AppBar from '@mui/material/AppBar';
import Box from '@mui/material/Box';
import Toolbar from '@mui/material/Toolbar';
import MenuIcon from '@mui/icons-material/Menu';
import IconButton from '@mui/material/IconButton';
import Button from '@mui/material/Button';
import Link from '@mui/material/Link';
import * as React from "react";
import AppBar from "@mui/material/AppBar";
import Box from "@mui/material/Box";
import Toolbar from "@mui/material/Toolbar";
import MenuIcon from "@mui/icons-material/Menu";
import IconButton from "@mui/material/IconButton";
import Button from "@mui/material/Button";
import Link from "@mui/material/Link";

import GitHubIcon from '@mui/icons-material/GitHub';
import Menu from '@mui/material/Menu';
import MenuItem from '@mui/material/MenuItem';


import { GITHUB_REPO } from '../config/contants';
import GitHubIcon from "@mui/icons-material/GitHub";
import Menu from "@mui/material/Menu";
import MenuItem from "@mui/material/MenuItem";
import { useTheme } from "@mui/material/styles";
import { GITHUB_REPO } from "../config/contants";
import { Typography } from "@mui/material";
export default function MenuAppBar() {
const pages = ["TV", "Radios", "Contributing"];
const [anchorEl, setAnchorEl] = React.useState(null);
const open = Boolean(anchorEl);
const handleClick = (event) => {
setAnchorEl(event.currentTarget);
};
const handleClose = () => {
setAnchorEl(null);
};
const theme = useTheme();
console.log(theme);
return (
<>
<Box sx={{ flexGrow: 1 }}>
<AppBar
position="fixed"
component="nav"
color="transparent"
style={{
backdropFilter: "blur(20px)",
// backgroundColor: "rgb(28 29 31 / 19%)",
boxShadow: "none",
borderBottom: `0.5px solid ${theme.palette.divider}`,
}}
>
<Toolbar>
<Menu
id="basic-menu"
anchorEl={anchorEl}
open={open}
onClose={handleClose}
MenuListProps={{
"aria-labelledby": "basic-button",
}}
>
{pages.map((page, i) => (
<MenuItem onClick={handleClose} key={i}>
{page}
</MenuItem>
))}
</Menu>
<Box sx={{ display: { xs: "block", md: "none" } }}>
<IconButton
size="large"
aria-label="account of current user"
aria-controls="menu-appbar"
aria-haspopup="true"
color="inherit"
edge="start"
onClick={handleClick}
>
<MenuIcon />
</IconButton>
</Box>

const pages = ['TV', 'Radios', 'Contributing'];
const [anchorEl, setAnchorEl] = React.useState(null);
const open = Boolean(anchorEl);
const handleClick = (event) => {
setAnchorEl(event.currentTarget);
};
const handleClose = () => {
setAnchorEl(null);
};

return (<>
<Box sx={{ flexGrow: 1 }}>
<AppBar position="fixed" component="nav">
<Toolbar>

<Menu
id="basic-menu"
anchorEl={anchorEl}
open={open}
onClose={handleClose}
MenuListProps={{
'aria-labelledby': 'basic-button',
}}
>
{pages.map((page, i) => (<MenuItem onClick={handleClose} key={i}>{page}</MenuItem>))}
</Menu>
<Box sx={{ display: { xs: 'block', md: 'none' } }}>
<IconButton
size="large"
aria-label="account of current user"
aria-controls="menu-appbar"
aria-haspopup="true"
color="inherit"
edge="start"
onClick={handleClick}>
<MenuIcon />
</IconButton>
</Box>


<img src="/logo.svg" alt="nahieran-js-logo" style={{ width: "200px" }} />

<Box sx={{ flexGrow: 1, display: { xs: 'none', md: 'flex' } }} justifyContent="center">

{pages.map((page, i) => (
<Link href={`#${page}`} key={i} color="inherit" underline="none">
<Button
key={page}
sx={{ my: 2, color: 'white', display: 'block' }}

>
{page}
</Button>
</Link>
))}
</Box>

<Link href={GITHUB_REPO} color="inherit" underline="none" target="_blank">
<IconButton
size="large"
aria-label="nahieran-js github repository"
aria-controls="menu-appbar"
aria-haspopup="true"
color="inherit"
edge="end"
>
<GitHubIcon />
</IconButton>
</Link>
</Toolbar>
</AppBar>

{/* <img
src="/logo.svg"
alt="nahieran-js-logo"
style={{ width: "200px" }}
/> */}
<Typography variant="h4">NahieranJS</Typography>
<Box
sx={{
flexGrow: 1,
marginLeft: 5,
display: { xs: "none", md: "flex" },
}}
// justifyContent="center"
>
{pages.map((page, i) => (
<Link
href={`#${page}`}
key={i}
color="inherit"
underline="none"
>
<Button key={page} sx={{ my: 2, display: "block" }}>
{page}
</Button>
</Link>
))}
</Box>

</Box>
</>);
}
<Link
href={GITHUB_REPO}
color="inherit"
underline="none"
target="_blank"
>
<IconButton
size="large"
aria-label="nahieran-js github repository"
aria-controls="menu-appbar"
aria-haspopup="true"
color="inherit"
edge="end"
>
<GitHubIcon />
</IconButton>
</Link>
</Toolbar>
</AppBar>
</Box>
</>
);
}
4 changes: 1 addition & 3 deletions nahieran-js-doc/src/Components/CodeCopyBtn/CodeCopyBtn.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
.doc-pre {
margin-bottom: 3em !important;
-webkit-box-shadow: -10px 0px 13px -7px #000000, 10px 0px 13px -7px #000000, 35px -23px 2px -16px rgba(0, 0, 0, 0);
box-shadow: -10px 0px 13px -7px #000000, 10px 0px 13px -7px #000000, 35px -23px 2px -16px rgba(0, 0, 0, 0);
/* margin-bottom: 3em !important; */
position: relative;
}

Expand Down
45 changes: 31 additions & 14 deletions nahieran-js-doc/src/Components/DocCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import {
Dialog,
DialogTitle,
DialogContent,
DialogContentText,
DialogActions,
TextField,
} from "@mui/material";
import MarkDown from "./MarkDown";

const DocCard = ({ title, markdown, demoFunction = null }) => {
const DocCard = ({ title, markdown, actionFunction = null, actionParam = null }) => {
const [openDialog, setOpenDialog] = useState(false);
const [dialogTitle, setDialogTitle] = useState("");
const [dialogContent, setDialogContent] = useState("");
Expand All @@ -24,24 +24,42 @@ const DocCard = ({ title, markdown, demoFunction = null }) => {
const demoFunctionHandler = () => {
setOpenDialog(true);
setDialogTitle("Get TV program list");
demoFunction && demoFunction().then((res) => {
console.log("OK: ", res);
setDialogContent(res);
});
actionFunction &&
actionFunction(demoFunctionParam|| null).then((res) => {
console.log("OK: ", res);
setDialogContent(res);
});
};

const [demoFunctionParam, setDemoFunctionParam] = useState(actionParam);
function demoFunctionParamChange(event) {
setDemoFunctionParam(event.target.value);
}
return (
<>
<Card variant="outlined">
<Card variant="outlined" sx={{ borderRadius: "20px" }}>
<CardContent>
<Typography variant="h3" color="text.secondary" gutterBottom>
{title}
</Typography>

<MarkDown markdown={markdown} />
</CardContent>
{demoFunction && (
<CardActions>
<Button size="small" onClick={demoFunctionHandler}>
{actionFunction && (
<CardActions style={{marginBottom: "10px",marginLeft:"10px", paddingTop: "none"}}>
{actionParam && (
<TextField
size="small"
label="Function parameter"
value={demoFunctionParam}
onChange={demoFunctionParamChange}
/>
)}

<Button
size="small"
onClick={demoFunctionHandler}
>
Try it!
</Button>
</CardActions>
Expand All @@ -55,10 +73,9 @@ const DocCard = ({ title, markdown, demoFunction = null }) => {
>
<DialogTitle id="alert-dialog-title">{dialogTitle}</DialogTitle>
<DialogContent>
<DialogContentText id="alert-dialog-description">
{dialogContent && JSON.stringify(dialogContent)}
{/* // <SyntaxHighlighter language="json"></SyntaxHighlighter> */}
</DialogContentText>
{dialogContent && (
<pre>{JSON.stringify(dialogContent, undefined, 4)}</pre>
)}
</DialogContent>
<DialogActions>
<Button onClick={handleClose} autoFocus>
Expand Down
4 changes: 2 additions & 2 deletions nahieran-js-doc/src/Components/MarkDown.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import React from "react";
import ReactMarkdown from "react-markdown";
import { Prism as SyntaxHighlighter } from "react-syntax-highlighter";
import CodeCopyBtn from "./CodeCopyBtn/CodeCopyBtn";

const MarkDown = ({ markdown }) => {
const Pre = ({ children }) => (
<pre className="doc-pre">
Expand All @@ -18,11 +17,12 @@ const MarkDown = ({ markdown }) => {
code({ node, inline, className, children, ...props }) {
const match = /language-(\w+)/.exec(className || "");
return !inline && match ? (
// @ts-ignore
<SyntaxHighlighter
children={String(children).replace(/\n$/, "")}
// style={docco}
language={match[1]}
PreTag="div"
className="border-radius"
{...props}
/>
) : (
Expand Down
8 changes: 5 additions & 3 deletions nahieran-js-doc/src/Docs/general.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
export const GETTING_STARTED = {
title:"Getting started",
description:`
This project is based on [@erral's](https://github.com/erral) [https://github.com/erral/eitbapi-react](https://github.com/erral/eitbapi-react) project.
description:`
A set of JS functions to use the EITB Nahieran API.
This project is based on [https://github.com/erral/eitbapi-react](https://github.com/erral/eitbapi-react) project.
A very special thanks to [@erral](https://github.com/erral) for the contribution made in this project. ❤️
A set of JS functions to use the EITB Nahieran API
## Install
~~~bash
npm i nahieran-js
Expand Down
Loading

0 comments on commit b5a9d81

Please sign in to comment.