Skip to content

Commit ab7af5a

Browse files
style: improve custom graph page and overall responsiveness
1 parent 656c331 commit ab7af5a

File tree

7 files changed

+175
-51
lines changed

7 files changed

+175
-51
lines changed

calc-frontend/src/App/app.css

Lines changed: 124 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,15 @@ body {
3838
width:100%;
3939

4040
margin:auto;
41-
padding-right:10px;
42-
padding-left:10px;
41+
padding-right:60px;
42+
padding-left:60px;
4343

4444
display:grid;
4545
grid-template-columns: 1fr 1fr 1fr 1fr;
4646
grid-template-rows: auto;
4747
column-gap:20px;
4848
row-gap:20px;
49+
4950
}
5051

5152
.topic-list-3{
@@ -54,19 +55,90 @@ body {
5455
}
5556

5657
.topic-box{
57-
@apply h-20 flex items-center justify-center
58-
bg-amber-300 rounded-lg hover:bg-amber-400 transition transform hover:scale-103
58+
@apply flex items-center justify-center
59+
bg-amber-300 hover:bg-amber-400 transition transform hover:scale-103
5960
duration-200 border-2 border-solid;
6061

62+
border-radius:8px;
63+
64+
height:calc(var(--spacing) * 20);
65+
max-width: calc(var(--spacing) * 20 * 3.5);
66+
}
67+
68+
.custom-border{
69+
overflow: hidden;
70+
71+
}
72+
73+
.custom-border:before{
74+
position:absolute;
75+
z-index:-2;
76+
height:450%;
77+
width:150%;
78+
79+
content:"";
80+
background-image: linear-gradient(to top right, #f46e29, #f46e29, #e93002,
81+
#DC1FFF, #1f57ff, #1fc7ff, #1fff7c, #1fff7c);
82+
83+
animation: spin 4s linear infinite;
84+
}
85+
86+
.custom-border:after{
87+
content: "";
88+
position:absolute;
89+
z-index:-1;
90+
91+
background: var(--color-amber-300);
92+
width: calc(100% - 8px);
93+
height: calc(100% - 8px);
94+
border-radius: 6px;
95+
96+
}
97+
98+
.custom-border:hover:after{
99+
background: var(--color-amber-400);
100+
}
101+
102+
@keyframes spin{
103+
100%{
104+
transform: rotate(-360deg);
105+
}
106+
}
107+
108+
.loading{
109+
animation: delay-appearance 300ms ease-out 1;
110+
}
111+
112+
@keyframes delay-appearance{
113+
0% {
114+
opacity: 0;
115+
}
116+
99% {
117+
opacity: 0;
118+
}
119+
100% {
120+
opacity: 1;
121+
}
61122
}
62123

63124
.back-button{
64125
@apply cursor-pointer bg-sky-400 hover:bg-blue-600 hover:text-neutral-50 rounded-md border-2 border-solid;
65-
padding: 4px 12px;
66-
font-size: 1.5rem;
126+
padding: 4px 16px;
127+
font-size: 1.375rem;
67128
margin-bottom: .75rem;
68129
}
69130

131+
.go-button{
132+
@apply cursor-pointer bg-[#1ee342] rounded-md border-2 border-solid;
133+
padding: 4px 12px;
134+
font-size: 1.375rem;
135+
height: fit-content;
136+
}
137+
138+
.brighten:hover {
139+
box-shadow: inset 1rem 5rem rgba(255, 255, 255, 0.3);
140+
}
141+
70142
.error-title{
71143
font-size: 3rem;
72144
line-height: 1;
@@ -99,10 +171,31 @@ body {
99171
max-width: 550px;
100172
}
101173

174+
.pad-sm{
175+
padding-right:.5rem;
176+
padding-left:.5rem;
177+
}
178+
102179
/*
103180
List the more inclusive media queries first if they
104181
should be overridden by subsequent queries
105182
*/
183+
@media (max-width: 1199px){
184+
185+
.topic-list{
186+
padding-right:40px;
187+
padding-left:40px;
188+
}
189+
}
190+
191+
@media (max-width: 1099px){
192+
193+
.topic-list{
194+
padding-right:20px;
195+
padding-left:20px;
196+
}
197+
}
198+
106199
@media (max-width: 999px) {
107200

108201
.topic-list{
@@ -121,24 +214,43 @@ body {
121214
@apply flex-wrap;
122215
}
123216

217+
.topic-list{
218+
padding-right:10px;
219+
padding-left:10px;
220+
}
124221
}
125222

126-
@media (max-width: 599px) {
127-
223+
@media (max-width: 699px) {
128224
.topic-list{
129225
grid-template-columns: 1fr 1fr;
130-
padding-right:0px;
131-
padding-left:0px;
226+
padding-right:40px;
227+
padding-left:40px;
228+
}
229+
230+
.topic-list-3{
231+
grid-template-columns: 1fr 1fr;
232+
}
233+
}
234+
235+
236+
@media (max-width: 599px) {
237+
.topic-list{
238+
padding-right:20px;
239+
padding-left:20px;
132240

133241
column-gap:15px;
134242
row-gap:15px;
135243
}
244+
}
136245

137-
.topic-list-3{
138-
grid-template-columns: 1fr 1fr;
246+
@media (max-width: 499px) {
247+
.topic-list{
248+
padding-right:0px;
249+
padding-left:0px;
139250
}
140251
}
141252

253+
142254
@media (min-width: 800px) {
143255

144256
.graph-frame{

calc-frontend/src/App/widgets.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,6 @@ h2 .mq-math-mode .mq-fraction{
2525
font-size:80%;
2626
}
2727

28+
.edit-box.mq-editable-field{
29+
padding-right:.25rem;
30+
}

calc-frontend/src/components/Custom/IntCustomGraph.tsx

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,17 +82,21 @@ function IntCustomGraph({func, lowerBound, upperBound}) {
8282
}
8383
}, [ready]);
8484

85+
if(!ready){
86+
return(
87+
<div className="pad-sm loading" style={{fontSize:'1.25rem'}}>
88+
Loading...<br/>
89+
Complex functions may take longer
90+
</div>
91+
)
92+
}
93+
94+
if(ready && !success){
95+
return <div className="pad-sm" style={{color:'red', fontSize: '1.25rem'}}>{errorMsg}</div>
96+
}
8597

8698
return (
87-
88-
ready?
89-
success? <div className="plotly-graph-div graph-frame" id="plotly_graph"></div> :
90-
<div style={{color:'red'}}>{errorMsg}</div>
91-
:
92-
<div style={{fontSize:'1.25rem'}}>
93-
Loading...<br/>
94-
Complex functions may take longer
95-
</div>
99+
<div className="plotly-graph-div graph-frame" id="plotly_graph"></div>
96100
)
97101

98102
}

calc-frontend/src/pages/CustomDerivative.tsx

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@ function CustomDeriv() {
77
const container = useRef<HTMLDivElement>(null);
88
const MQ = useRef<any>(null);
99
const containerMF = useRef<any>(null);
10+
const start = useRef<HTMLDivElement>(null);
1011

1112
const edit = useRef<HTMLDivElement>(null);
1213
const editMF = useRef<any>(null);
1314
const [func, setFunc] = useState<string>('');
1415
const [bounds, setBounds] = useState<number[]>([0,5]);
16+
const [formatCheck, setFormatCheck] = useState<string>('');
1517

1618
/*
1719
Updates the function and the bounds with the user input
@@ -26,7 +28,7 @@ function CustomDeriv() {
2628
newFunc = generateFunction(funcLatex)
2729
}
2830
catch{
29-
console.log('Please enter a valid function')
31+
setFormatCheck('Please enter a valid function')
3032
return 1
3133
}
3234

@@ -37,13 +39,15 @@ function CustomDeriv() {
3739

3840
// check if bounds are valid
3941
if(checkBounds !== 'success'){
40-
console.log(checkBounds)
42+
setFormatCheck(checkBounds)
4143
return 1
4244
}
4345

4446
// input is valid, so set all variables
4547
setFunc(newFunc)
4648
setBounds([parseFloat(lowerBound), parseFloat(upperBound)])
49+
setFormatCheck('')
50+
4751

4852
return 0
4953
}
@@ -55,10 +59,10 @@ function CustomDeriv() {
5559

5660
containerMF.current = MQ.current.StaticMath(container.current, { }) // for the bounds
5761

58-
editMF.current = MQ.current.StaticMath(edit.current).innerFields[0] // for the function
62+
MQ.current.StaticMath(start.current, { }) // for the y =
5963

6064
// updates the output whenever 'enter' is pressed
61-
editMF.current.config({
65+
editMF.current = MQ.current.MathField(edit.current, {
6266
handlers: {
6367
enter: generateOutput
6468
}
@@ -73,23 +77,25 @@ function CustomDeriv() {
7377
<button className="back-button"> Back</button>
7478
</Link>
7579

76-
<div className="center-header flex flex-wrap justify-center gap-[1rem]">
80+
<div className="center-header flex flex-wrap justify-center gap-[1rem]" style={{alignItems:"center"}}>
7781
<div ref={container}>
7882
\MathQuillMathField&#123;0&#125; \leq x \leq \MathQuillMathField&#123;5&#125;
7983
</div>
8084

81-
<div ref={edit}>
82-
y = \MathQuillMathField&#123;x&#125;
85+
<div>
86+
<div ref={start}>
87+
y =
88+
</div>
89+
90+
<div ref={edit} className = "edit-box">
91+
x
92+
</div>
8393
</div>
8494

8595
</div>
8696

87-
<div style={{display:'block', marginBottom:'0.5rem'}} className='center-header'>
88-
{func} &nbsp;&nbsp;{bounds.join(', ')}
89-
</div>
90-
91-
<div className="graph-outer-box" style={{justifyContent: "center"}}>
92-
The graph will go here
97+
<div className="center-header" style={{fontSize:'1.5rem'}}>
98+
Coming Soon
9399
</div>
94100

95101
</div>

calc-frontend/src/pages/CustomIntegral.tsx

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,13 @@ function CustomInt() {
7676
<button className="back-button"> Back</button>
7777
</Link>
7878

79-
<div className="center-header flex flex-wrap justify-center gap-[.5rem]">
79+
<div className="center-header flex flex-wrap justify-center gap-[.5rem]" style={{alignItems:"center"}}>
8080
<div ref={container} >
8181
\int_\MathQuillMathField&#123;0&#125;^\MathQuillMathField&#123;5&#125;
8282
</div>
8383

84-
<div style={{height:'fit-content', alignSelf:'center'}}>
85-
<div ref={edit} style={{marginRight:'.25rem'}}>
84+
<div style={{height:'fit-content', alignSelf:'center', marginRight:'.5rem'}}>
85+
<div ref={edit} className = "edit-box" style={{marginRight:'.25rem'}}>
8686
x
8787
</div>
8888

@@ -91,23 +91,22 @@ function CustomInt() {
9191
</div>
9292
</div>
9393

94+
<button className="go-button brighten" onClick={generateOutput}> Graph</button>
95+
9496
</div>
9597

9698
{
97-
formatCheck === ''? null :
98-
<div className="center-header" style={{fontSize:'1rem', color:'red'}}>
99-
{formatCheck}
100-
</div>
99+
formatCheck === ''? func === ''? null :
100+
<div className="graph-outer-box" style={{justifyContent: "center", marginTop:'.5rem'}}>
101+
<IntCustomGraph key={func + bounds[0].toString() + bounds[1].toString()} func={func}
102+
lowerBound = {bounds[0]} upperBound = {bounds[1]}/>
103+
</div>
104+
:
105+
<div className="center-header pad-sm" style={{fontSize:'1.25rem', color:'red', marginTop:'.5rem'}}>
106+
{formatCheck}
107+
</div>
101108
}
102109

103-
{
104-
func === ''? null :
105-
<div className="graph-outer-box" style={{justifyContent: "center", marginTop:'.5rem'}}>
106-
<IntCustomGraph key={func + bounds[0].toString() + bounds[1].toString()} func={func}
107-
lowerBound = {bounds[0]} upperBound = {bounds[1]}/>
108-
</div>
109-
}
110-
111110
</div>
112111
)
113112
}

calc-frontend/src/pages/Derivatives.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function Derivatives() {
1313
<h2 className="topic-header m-auto w-fit">The Derivative of Common Functions</h2>
1414
<div className="topic-list">
1515

16-
<Link to="/derivatives/custom" className="topic-box">
16+
<Link to="/derivatives/custom" className="topic-box custom-border">
1717
<button className="link-title cursor-pointer">Custom</button>
1818
</Link>
1919

calc-frontend/src/pages/Integrals.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function Integrals() {
1313
<h2 className="topic-header m-auto w-fit">The Integral of Common Functions</h2>
1414
<div className="topic-list">
1515

16-
<Link to="/integrals/custom" className="topic-box">
16+
<Link to="/integrals/custom" className="topic-box custom-border">
1717
<button className="link-title cursor-pointer">Custom</button>
1818
</Link>
1919

0 commit comments

Comments
 (0)