Skip to content

Commit

Permalink
Merge pull request #1597 from clpetersonucf/issue/1590-improve-pre-em…
Browse files Browse the repository at this point in the history
…bed-view

Improves widget pre-embed views
  • Loading branch information
clpetersonucf authored Aug 2, 2024
2 parents ab288f6 + d9f5547 commit 9b5f41e
Show file tree
Hide file tree
Showing 8 changed files with 128 additions and 61 deletions.
2 changes: 2 additions & 0 deletions src/components/closed.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { useEffect, useState } from 'react';
import Header from './header'
import Summary from './widget-summary'
import './login-page.scss'
import EmbedFooter from './widget-embed-footer';

const Closed = () => {

Expand Down Expand Up @@ -45,6 +46,7 @@ const Closed = () => {
<Summary />
<h3>{ state.summary }</h3>
<p>{ state.description }</p>
<EmbedFooter/>
</section>
</div>
</>
Expand Down
21 changes: 12 additions & 9 deletions src/components/embedded-only.jsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
import React from 'react';
import Summary from './widget-summary'
import EmbedFooter from './widget-embed-footer';

const EmbeddedOnly = () => {
return (
<div className="container widget">
<section className="page">
<Summary/>
<div className="container widget">
<section className="page">
<Summary/>

<div className="detail icon-offset">
<h2 className="unavailable-text">Not Playable Here</h2>
<span className="unavailable-subtext">Your instructor has not made this widget available outside of the LMS.</span>
</div>
</section>
</div>
<div className="detail icon-offset">
<h2 className="unavailable-text">Not Playable Here</h2>
<span className="unavailable-subtext">Your instructor has not made this widget available outside of the LMS.</span>
</div>

<EmbedFooter/>
</section>
</div>
)
}

Expand Down
2 changes: 2 additions & 0 deletions src/components/login-page.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { useEffect, useRef, useState } from 'react'
import Header from './header'
import Summary from './widget-summary'
import './login-page.scss'
import EmbedFooter from './widget-embed-footer'

const LoginPage = () => {

Expand Down Expand Up @@ -107,6 +108,7 @@ const LoginPage = () => {
: '' }
</form>
</div>
{ state.context && state.context == 'widget' ? <EmbedFooter /> : ''}
</section>
</div>
</>
Expand Down
2 changes: 1 addition & 1 deletion src/components/login-page.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@

span.subtitle {
font-size: .7em;
font-weight: 300;
font-weight: 400;
}
73 changes: 38 additions & 35 deletions src/components/no-attempts.jsx
Original file line number Diff line number Diff line change
@@ -1,53 +1,56 @@
import React, { useState, useEffect} from 'react'
import Summary from './widget-summary'
import Header from './header'
import EmbedFooter from './widget-embed-footer'

const NoAttempts = () => {
const [attempts, setAttempts] = useState(null)
const [scoresPath, setScoresPath] = useState(null)
const [attempts, setAttempts] = useState(null)
const [scoresPath, setScoresPath] = useState(null)

useEffect(() => {
waitForWindow().then(() => {
const scoresPath = `/scores${window.IS_EMBEDDED ? '/embed' : ''}/${window.WIDGET_ID}`;
useEffect(() => {
waitForWindow().then(() => {
const scoresPath = `/scores${window.IS_EMBEDDED ? '/embed' : ''}/${window.WIDGET_ID}`;

setScoresPath(scoresPath);
setAttempts(window.ATTEMPTS)
})
}, [])
setScoresPath(scoresPath);
setAttempts(window.ATTEMPTS)
})
}, [])

const waitForWindow = async () => {
const waitForWindow = async () => {
while(!window.hasOwnProperty('WIDGET_ID')
&& !window.hasOwnProperty('IS_EMBEDDED')
&& !window.hasOwnProperty('ATTEMPTS')) {
await new Promise(resolve => setTimeout(resolve, 500))
}
}

let bodyRender = null
if (!!attempts) {
bodyRender = (
<div className={"container widget"}>
<section className="attempts page">
<Summary/>

<div className="detail icon-offset">
<h2 className="unavailable-text">No remaining attempts</h2>
<span className="unavailable-subtext">You've used all { attempts } available attempts.</span>
<p>
<a href={ scoresPath }>Review previous scores</a>
</p>
</div>
</section>
</div>
)
}

return (
<>
<Header />
{ bodyRender }
</>
)
let bodyRender = null
if (!!attempts) {
bodyRender = (
<div className={"container widget"}>
<section className="attempts page">
<Summary/>

<div className="detail icon-offset">
<h2 className="unavailable-text">No remaining attempts</h2>
<span className="unavailable-subtext">You've used all { attempts } available attempts.</span>
<p>
<a href={ scoresPath }>Review previous scores</a>
</p>
</div>

<EmbedFooter/>
</section>
</div>
)
}

return (
<>
<Header />
{ bodyRender }
</>
)
}

export default NoAttempts
67 changes: 53 additions & 14 deletions src/components/pre-embed-common-styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,17 @@ body {
text-align: center;
clear: both;

&.pre-embed {
padding: 2em 0;

background: #f3f3f3;
border-radius: 4px;

.action_button {
margin: 24px;
}
}

h2 {
font-size: 18pt;
}
Expand Down Expand Up @@ -102,11 +113,22 @@ body {

.widget_info {
position: relative;
display: flex;
justify-content: flex-start;
align-items: center;
gap: 1em;
min-height: 122px;
padding-left: 110px;
width: calc(100% + 20px);

list-style: none;
top: -15px;
left: -10px;

border-top-left-radius: 4px;
border-top-right-radius: 4px;

background: #0093e7;
color: #fff;

li {
display: block;
margin-right: 10px;
Expand All @@ -126,18 +148,7 @@ body {
}

.widget_icon {
position: absolute;
top: 0;
left: -25px;
background: #0093e7;
width: 92px;
height: 92px;
padding: 15px;
text-align: center;
color: #fff;
font-size: 10px;
line-height: 13px;
box-shadow: 0px 2px 2px rgba(0, 0, 0, 0.4);
padding-left: 15px;

img {
width: 92px;
Expand All @@ -149,6 +160,7 @@ body {
}

ul.widget_about {
margin: 0;
padding: 0;
list-style-type: none;

Expand All @@ -169,6 +181,33 @@ body {
}
}

.widget-embed-footer {
position: absolute;
bottom: 5px;

display: flex;
justify-content: space-between;
align-items: center;

width: calc(100% - 20px);

font-size: 0.7em;
font-weight: 400;

color: #5e5e5e;

a {
&.materia-logo {

img {
width: auto;
height: 15px;
margin-top: 1px;
}
}
}
}

div#form {

ul {
Expand Down
7 changes: 5 additions & 2 deletions src/components/pre-embed-placeholder.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import React, { useState, useEffect} from 'react'
import Summary from './widget-summary'
import EmbedFooter from './widget-embed-footer'

import './pre-embed-common-styles.scss'


const PreEmbedPlaceholder = () => {

const [instId, setInstId] = useState(null)
Expand All @@ -27,9 +29,10 @@ const PreEmbedPlaceholder = () => {
<div className="container widget">
<section className="page">
<Summary/>
<div className="detail icon-offset">
<a className="action_button" href={`/${context}/${instId}`}>Play</a>
<div className="detail pre-embed">
<a className="action_button" href={`/${context}/${instId}`}>Play Widget</a>
</div>
<EmbedFooter/>
</section>
</div>
)
Expand Down
15 changes: 15 additions & 0 deletions src/components/widget-embed-footer.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React from 'react'

const EmbedFooter = () => {

return (
<section className='widget-embed-footer'>
<a className="materia-logo" href={window.BASE_URL} target="_blank"><img src="/img/materia-logo-thin.svg" alt="materia logo" /></a>
<span>
Content embedded from Materia. Need a hand? View <a className='inline-link' href={`${window.BASE_URL}/help#students`} target='_blank'>support options</a>.
</span>
</section>
)
}

export default EmbedFooter

0 comments on commit 9b5f41e

Please sign in to comment.