Skip to content

Commit

Permalink
Add responsive layout
Browse files Browse the repository at this point in the history
  • Loading branch information
tmarti committed Jun 6, 2024
1 parent 2ea27a4 commit 159779d
Show file tree
Hide file tree
Showing 8 changed files with 143 additions and 33 deletions.
130 changes: 127 additions & 3 deletions src/App.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#root {
max-width: 1280px;
/* max-width: 1280px; */
margin: 0 auto;
padding: 2rem;
/* padding: 2rem; */
text-align: center;
}

Expand Down Expand Up @@ -41,7 +41,7 @@
color: #888;
}

#main-div {
/* #main-div {
display: flex;
width: 100%;
height: 100%;
Expand All @@ -56,4 +56,128 @@
flex-grow: 1;
margin: 5px;
}
*/


#main-div {
display: flex;
height: 100vh; /* Full viewport height */
width: 100vw; /* Full viewport width */
}

#left-pane {
display: flex;
flex-direction: column;
height: 100%;
width: 20%; /* 20% of horizontal space as per your diagram */
border: 1px solid lightgray;
padding: 0 2rem;
}

#right-pane {
height: 100%;
width: 80%; /* 80% of horizontal space as per your diagram */
}

.PanelConceptCategories {
height: 70%; /* 70% of vertical space */
overflow-y: scroll; /* Enable vertical scrolling */
}

.PanelMyConcept {
height: 30%; /* 30% of vertical space */
}

.Panel3D {
height: 100%; /* 100% of vertical space */
width: 100%; /* Using full width of its container */
border: 1px solid lightgray;
}

.ItemOpenAiKey {
position: fixed; /* Fix position relative to the viewport */
bottom: 1rem; /* Align to the top of the viewport */
right: 1rem; /* Position at the center of the viewport */
/* transform: translateX(-50%); Shift left by half its width to center it */
width: auto; /* Auto width based on content */
z-index: 1000; /* Ensure it's above other content */
background: lightyellow;
padding: 1rem;
border: 1px solid lightgray;
border-radius: 10px;
}

.CardHoveredConcept {
position: fixed; /* Fix position relative to the viewport */
bottom: 1rem; /* Align to the top of the viewport */
left: calc(20% + 4rem); /* Position at the center of the viewport */
/* transform: translateX(-50%); Shift left by half its width to center it */
width: auto; /* Auto width based on content */
z-index: 1000; /* Ensure it's above other content */
background: lightyellow;
padding: 1rem;
border: 1px solid lightgray;
border-radius: 10px;
margin-left: 1rem;
}

.HiddenOnMobile {
display: block;
}

.SelectConcept {
max-width: 100%;
/* z-index: 2000;; */
margin: 1rem 0;
}

/* Mobile styles using a media query */
@media (max-width: 600px) { /* Adjust breakpoint as needed */
#main-div {
flex-direction: column; /* Stack vertically for mobile */
}

#left-pane, #right-pane {
width: 100%; /* Full width on mobile */
}

#right-pane {
height: 50%;
}

#left-pane {
height: 50%;
padding: 0;
}

.PanelConceptCategories {
width: calc(100% - 2rem);
padding: 0;
margin: 1rem;
height: 170px; /* 20% of vertical space */
margin-bottom: 0;
}

.PanelMyConcept {
width: 100%; /* Full width */
/* Height auto-adjusts based on content */
padding-bottom: 1rem;
padding: 0;
margin: 1rem;
}

.Panel3D {
height: 50%;
/* flex-grow: 1; Takes remaining space */
width: 100%; /* Full width */
height: unset;
}

.HiddenOnMobile {
display: none;
}

.SelectConcept {
max-width: 85%;
}
}
14 changes: 1 addition & 13 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,6 @@ function App() {
setConcepts(concepts.slice());
};


setTimeout(
() => {
(document.getElementById('three-canvas') as HTMLCanvasElement).style.height = '100%';
},
400
)

return (
<>
<ItemOpenAiKey/>
Expand All @@ -56,11 +48,6 @@ function App() {
<PanelMyConcept
onChangeMyConcept={fnChangeCustomConcept}
/>
{hoveredIndex != -1 &&
<CardHoveredConcept
text={`${concepts[hoveredIndex].label}`}
/>
}
</div>
<div id="right-pane">
<Panel3D
Expand All @@ -69,6 +56,7 @@ function App() {
onHoverConcept={setHoveredIndex}/>
</div>
</div>
{hoveredIndex != -1 && <CardHoveredConcept text={`${concepts[hoveredIndex].label}`}/>}
</>
)
}
Expand Down
11 changes: 3 additions & 8 deletions src/CardHoveredConcept.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,8 @@ export const CardHoveredConcept = ({
text: string,
}) => {
return (
<h4 style={{
border: '1px black solid',
borderRadius: '8px',
width: 'fit-content',
padding: '8px',
}}>
<em>{text}</em>
</h4>
<div className="CardHoveredConcept HiddenOnMobile">
<strong><em>{text}</em></strong>
</div>
);
}
4 changes: 2 additions & 2 deletions src/ItemOpenAiKey.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
export const ItemOpenAiKey = () => {
return (
<div style={{ padding: '3px', textAlign: 'left' }}>
<div className="ItemOpenAiKey">
OpenAI API key&nbsp;
<input
id='llm-key'
style={{width: '400px'}}
style={{width: '200px'}}
type='password'
/>
</div>
Expand Down
1 change: 1 addition & 0 deletions src/ListItemConcept.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export const ListItemConcept = ({
return (
<div style={{ display: 'flex', alignItems: 'center', padding: '3px' }}>
<span
className="HiddenOnMobile"
style={{
height: '20px', // Ensures the circle is 20px in diameter
width: '20px', // Matching width and height for a perfect circle
Expand Down
2 changes: 1 addition & 1 deletion src/Panel3D.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export const Panel3D = ({
)
}
return (
<Canvas id="three-canvas">
<Canvas id="three-canvas" className='Panel3D'>
{/* PerspectiveCamera from drei automatically becomes the default camera */}
<PerspectiveCamera
makeDefault
Expand Down
10 changes: 6 additions & 4 deletions src/PanelConceptCategories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,14 @@ export const PanelConceptCategories = ({
};

return (
<>
<h3 style={{textAlign: 'left'}}># Categories</h3>
<div className='PanelConceptCategories'>
<h3 style={{textAlign: 'left'}}># Categories</h3>
<Select
// ref={select}
className="SelectConcept"
placeholder="pick a concept..."
isSearchable={false}
menuPortalTarget={document.body}
options={Object.keys(conceptCategories).map(
x => {
return {
Expand All @@ -51,7 +53,7 @@ export const PanelConceptCategories = ({
)}
onChange={ev => onSelectionChange(ev?.value || "")}
/>
<h2 style={{height:'300px', overflow:'scroll'}}>
<h2 style={{height:'300px', overflow:'scroll'}} className="HiddenOnMobile">
{concepts.map(x => (
<ListItemConcept
color={x.color}
Expand All @@ -67,7 +69,7 @@ export const PanelConceptCategories = ({
Represent Category
</button>
</div>
</>
</div>
);

}
4 changes: 2 additions & 2 deletions src/PanelMyConcept.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const PanelMyConcept = ({
onChangeMyConcept: (concept: string) => void,
}) => {
return (
<>
<div className='PanelMyConcept'>
<h3 style={{textAlign:'left' }}># Your Concept</h3>
<h2>
<ListItemConcept
Expand All @@ -23,7 +23,7 @@ export const PanelMyConcept = ({
Represent Concept
</button>
</div>
</>
</div>
);

}

0 comments on commit 159779d

Please sign in to comment.