MCPcopy
hub / github.com/UdaraJay/Pile / PileLayout

Function PileLayout

src/renderer/pages/Pile/Layout.jsx:18–98  ·  view source on GitHub ↗
({ children })

Source from the content-addressed store, hash-verified

16import Chat from './Chat';
17
18export default function PileLayout({ children }) {
19 const { pileName } = useParams();
20 const { index, refreshIndex } = useIndexContext();
21 const { visibleIndex, closestDate } = useTimelineContext();
22 const { currentTheme } = usePilesContext();
23
24 const [now, setNow] = useState(DateTime.now().toFormat('cccc, LLL dd, yyyy'));
25
26 useEffect(() => {
27 try {
28 if (visibleIndex < 5) {
29 setNow(DateTime.now().toFormat('cccc, LLL dd, yyyy'));
30 } else {
31 setNow(DateTime.fromISO(closestDate).toFormat('cccc, LLL dd, yyyy'));
32 }
33 } catch (error) {
34 console.log('Failed to render header date');
35 }
36 }, [visibleIndex, closestDate]);
37
38 useEffect(() => {
39 window.scrollTo(0, 0);
40 }, []);
41
42 const themeStyles = useMemo(() => {
43 return currentTheme ? currentTheme + 'Theme' : '';
44 }, [currentTheme]);
45
46 const osStyles = useMemo(
47 () => (window.electron.isMac ? styles.mac : styles.win),
48 []
49 );
50
51 return (
52 <div className={`${styles.frame} ${themeStyles} ${osStyles}`}>
53 <div className={styles.bg}></div>
54 <div className={styles.main}>
55 <div className={styles.sidebar}>
56 <div className={styles.top}>
57 <div className={styles.part}>
58 <div className={styles.count}>
59 <span>{index.size}</span> entries
60 </div>
61 </div>
62 </div>
63 <Sidebar />
64 </div>
65 <div className={styles.content}>
66 <div className={styles.nav}>
67 <div className={styles.left}>
68 {pileName} <span style={{ padding: '6px' }}>·</span>
69 <motion.span
70 key={now}
71 initial={{ opacity: 0 }}
72 animate={{ opacity: 1 }}
73 exit={{ opacity: 0 }}
74 transition={{ duration: 0.5 }}
75 >

Callers

nothing calls this directly

Calls 3

useIndexContextFunction · 0.90
useTimelineContextFunction · 0.90
usePilesContextFunction · 0.90

Tested by

no test coverage detected