-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
615 additions
and
214 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
import { List, ListItem, Stack } from '@mui/material'; | ||
|
||
import { CCLicenseAdaptions } from '@graasp/sdk'; | ||
|
||
import { useLibraryTranslation } from '../../../config/i18n'; | ||
import LIBRARY from '../../../langs/constants'; | ||
import CreativeCommons from '../../common/CreativeCommons'; | ||
|
||
type Props = { | ||
ccLicenseAdaption?: CCLicenseAdaptions; | ||
url: string; | ||
title: string; | ||
production?: string; | ||
duration?: string; | ||
edition?: string; | ||
}; | ||
|
||
const VideoWithCC = ({ | ||
url, | ||
title, | ||
ccLicenseAdaption = CCLicenseAdaptions.CC_BY_SA, | ||
production, | ||
duration, | ||
edition, | ||
}: Props): JSX.Element => { | ||
const { t } = useLibraryTranslation(); | ||
|
||
return ( | ||
<Stack | ||
p={3} | ||
style={{ | ||
borderRadius: 20, | ||
border: '1px solid lightgrey', | ||
textAlign: 'center', | ||
background: 'white', | ||
width: 'fit-content', | ||
margin: 'auto', | ||
}} | ||
gap={3} | ||
alignContent="center" | ||
> | ||
<Stack direction="row" justifyContent="center" alignItems="center"> | ||
<iframe | ||
style={{ margin: 'auto', border: 'none', display: 'block' }} | ||
width="560" | ||
height="315" | ||
src={url} | ||
title={title} | ||
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" | ||
allowFullScreen | ||
/> | ||
</Stack> | ||
<Stack direction="row" justifyContent="center" alignItems="center"> | ||
<Stack> | ||
<List dense> | ||
{production && ( | ||
<ListItem> | ||
<strong> | ||
{t(LIBRARY.OER_INFORMATION_VIDEO_DESCRIPTION_PRODUCTION)} | ||
</strong> | ||
: {production} | ||
</ListItem> | ||
)} | ||
{duration && ( | ||
<ListItem> | ||
<strong> | ||
{t(LIBRARY.OER_INFORMATION_VIDEO_DESCRIPTION_DURATION)} | ||
</strong> | ||
: {duration} | ||
</ListItem> | ||
)} | ||
{edition && ( | ||
<ListItem> | ||
<strong> | ||
{t(LIBRARY.OER_INFORMATION_VIDEO_DESCRIPTION_EDITION)} | ||
</strong> | ||
: {edition} | ||
</ListItem> | ||
)} | ||
</List> | ||
</Stack> | ||
<Stack> | ||
{ccLicenseAdaption && ( | ||
<CreativeCommons | ||
iconSize={30} | ||
ccLicenseAdaption={ccLicenseAdaption} | ||
/> | ||
)} | ||
</Stack> | ||
</Stack> | ||
</Stack> | ||
); | ||
}; | ||
|
||
export default VideoWithCC; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import React, { useMemo } from 'react'; | ||
|
||
import { Typography } from '@mui/material'; | ||
|
||
import { DiscriminatedItem } from '@graasp/sdk'; | ||
import { | ||
CCSharingVariant, | ||
CreativeCommons as GraaspCreativeCommons, | ||
} from '@graasp/ui'; | ||
|
||
import { useLibraryTranslation } from '../../config/i18n'; | ||
import LIBRARY from '../../langs/constants'; | ||
|
||
const convertLicense = (ccLicenseAdaption: string) => { | ||
// Legacy licenses. | ||
if (['alike', 'allow'].includes(ccLicenseAdaption)) { | ||
return { | ||
requireAccreditation: true, | ||
allowCommercialUse: true, | ||
allowSharing: ccLicenseAdaption === 'alike' ? 'alike' : 'yes', | ||
}; | ||
} | ||
|
||
return { | ||
requireAccreditation: ccLicenseAdaption?.includes('BY'), | ||
allowCommercialUse: !ccLicenseAdaption?.includes('NC'), | ||
allowSharing: (() => { | ||
if (!ccLicenseAdaption || !ccLicenseAdaption.length) { | ||
return ''; | ||
} | ||
if (ccLicenseAdaption?.includes('SA')) { | ||
return 'alike'; | ||
} | ||
return ccLicenseAdaption?.includes('ND') ? 'no' : 'yes'; | ||
})(), | ||
}; | ||
}; | ||
|
||
type Props = { | ||
id?: string; | ||
ccLicenseAdaption: DiscriminatedItem['settings']['ccLicenseAdaption']; | ||
iconSize?: number; | ||
}; | ||
|
||
const CreativeCommons = ({ | ||
id, | ||
ccLicenseAdaption, | ||
iconSize = 48, | ||
}: Props): JSX.Element => { | ||
const { t } = useLibraryTranslation(); | ||
|
||
const { allowSharing, allowCommercialUse, requireAccreditation } = useMemo( | ||
() => convertLicense(ccLicenseAdaption ?? ''), | ||
[ccLicenseAdaption], | ||
); | ||
|
||
if (ccLicenseAdaption && ccLicenseAdaption.length > 0) { | ||
return ( | ||
<GraaspCreativeCommons | ||
allowSharedAdaptation={allowSharing as CCSharingVariant} | ||
allowCommercialUse={allowCommercialUse} | ||
requireAccreditation={requireAccreditation} | ||
iconSize={iconSize} | ||
sx={{ marginY: 0, paddingY: 0 }} | ||
/> | ||
); | ||
} | ||
|
||
return ( | ||
<Typography variant="body1" color="text.secondary" id={id}> | ||
{t(LIBRARY.SUMMARY_DETAILS_EMPTY_LICENSE_TEXT)} | ||
</Typography> | ||
); | ||
}; | ||
|
||
export default CreativeCommons; |
Oops, something went wrong.