Skip to content

Commit

Permalink
Core 4461 membership documentation on about (#833) (#834)
Browse files Browse the repository at this point in the history
* update dataset text

* update carousel

* updates

* component

* update active state

* update link issue

* scroll issue to carousel

* Add SCP police

* update header text

* update scroll issue from cards

* Add SCP police

* Remove SCP police

* remove unused files

* remove unused import

---------

Co-authored-by: ekachxaidze98 <[email protected]>
  • Loading branch information
valeriibudko and ekachxaidze98 authored Feb 17, 2023
1 parent c9fb298 commit 0c1fee1
Show file tree
Hide file tree
Showing 14 changed files with 932 additions and 915 deletions.
240 changes: 186 additions & 54 deletions data/membership.yml

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions design-v2/components/membership-table/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,19 +111,19 @@ const MembershipTable = observe(
<tr key={row.title}>
<td
className={classNames.use(styles.cellDetailsFirst, {
[styles.cellBackGround]: !row.description,
[styles.cellBackGround]: !row.descriptionCardTable,
})}
>
<Markdown
className={classNames.use(styles.cellTitle, {
[styles.cellPadding]: !row.description,
[styles.cellPadding]: !row.descriptionCardTable,
})}
>
{row.title}
</Markdown>
{row.description ? (
{row.descriptionCardTable ? (
<Markdown className={styles.cellDescription}>
{row.description}
{row.descriptionCardTable}
</Markdown>
) : (
<></>
Expand Down
987 changes: 233 additions & 754 deletions package-lock.json

Large diffs are not rendered by default.

45 changes: 45 additions & 0 deletions pages/membership-documentation/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import React, { useState } from 'react'

import DocumentationPageTemplate from '../../templates/membership-documentation'

import retrieveContent from 'content'

const ASSETS_BASE_URL = 'https://oacore.github.io/content/'

const DocumentationPage = ({ ...props }) => {
const [stateData, setStateData] = useState({})

const setAssetsUrl = (object) => {
Object.entries(object).forEach(([, value]) => {
delete value.membership
if (value.images) {
Object.entries(value.images).forEach(([, item]) => {
item.file = ASSETS_BASE_URL + item.file
})
}
})
}

const getSections = async ({ ref } = {}) => {
const content = await retrieveContent('docs-membership', {
ref,
transform: 'object',
})

delete content.headerDashboard
Object.values(content).forEach((section) => {
if (section.items) setAssetsUrl(section.items)
})

return content
}
if (Object.getOwnPropertyNames(stateData).length === 0) {
getSections().then((val) => {
setStateData(val)
})
return <></>
}
return <DocumentationPageTemplate {...props} {...stateData} />
}

export default DocumentationPage
3 changes: 3 additions & 0 deletions public/images/membership/activeArrow.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
67 changes: 67 additions & 0 deletions public/images/membership/oxford.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions public/images/membership/video.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/screenshots/video.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
65 changes: 65 additions & 0 deletions templates/membership-documentation/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import React, { useEffect, useState } from 'react'
import {
DocumentationMembership,
DocumentationMembershipNav,
} from '@oacore/design/lib/modules'
import { useRouter } from 'next/router'

import Markdown from '../../components/markdown'
import { Layout } from '../../design-v2/components'
import textData from '../../data/membership.yml'

function normalizeHref(str) {
const test = str.replace('#', '')
return test.replace('_', '-')
}

const DocumentationPageTemplate = ({ headerAbout, docs }) => {
const [highlight, setHighlight] = useState()
const [navActiveIndex, setNavActiveIndex] = useState(null)
const route = useRouter()
useEffect(() => {
const id = route.query?.r
if (id) {
setTimeout(() => {
document.getElementById(id).scrollIntoView({
behavior: 'smooth',
block: 'center',
})
const n = docs.items.findIndex((item) => item.id === id)
setHighlight(n)
}, 100)
}
}, [route.query.r])

useEffect(() => {
const id = route.query?.r
if (id) {
const n = textData.navItems.findIndex(
(item) => normalizeHref(item.href) === id
)
setNavActiveIndex(n)
}
}, [])
return (
<Layout>
<DocumentationMembership
headerTitle={headerAbout.header.title}
headerCaption={<Markdown>{headerAbout.header.caption}</Markdown>}
docs={docs}
highlight={highlight}
setHighlight={setHighlight}
nav={
<DocumentationMembershipNav
activeIndex={navActiveIndex}
setNavActiveIndex={setNavActiveIndex}
textData={textData}
setHighlight={setHighlight}
/>
}
/>
</Layout>
)
}

export default DocumentationPageTemplate
115 changes: 115 additions & 0 deletions templates/membership-documentation/styles.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
.documentation-wrapper {
margin: 15px 0;
}

.documentation-inner-wrapper {
width: calc(100vw - 370px);
overflow-y: scroll;
}

.documentation-header {
font-size: 24px;
font-style: normal;
font-weight: 500;
line-height: 24px;
color: #212121;
}

.documentation-sub-title {
font-size: 16px;
font-style: normal;
font-weight: 400;
line-height: 24px;
color: #212121;
}

.placement {
display: flex;
justify-content: space-between;
max-height: 1472px;
overflow-y: scroll;
padding-top: 24px;
border-top: 2px solid #b75400;
}

.documentation-item {
padding: 8px 0;
border-bottom: 2px dashed #eee;
p {
margin-top: 24px;
}
}

.documentation-item ul {
margin-left: 1.5rem;
}

.documentation-item li {
line-height: 2rem;
list-style-type: disc;
}

.documentation-item-title {
margin-bottom: 10px;
font-size: 18px;
font-style: normal;
font-weight: 700;
line-height: 24px;
color: #212121;
}

.documentation-text {
font-size: 16px;
font-style: normal;
font-weight: 400;
line-height: 24px;
color: #212121;
}

.membership {
display: flex;
align-items: center;
justify-content: center;
width: max-content;
height: 24px;
padding: 8px;
font-size: 14px;
font-style: normal;
font-weight: 400;
text-transform: capitalize;
border-radius: 2px;
}

.image {
width: 100%;
margin-bottom: 24px;
object-fit: contain;
}

.logo-banner {
width: 50%;
}

.logo-personalised {
width: 50%;
}

.type-wrapper {
display: flex;
align-items: center;
gap: 4px;
}

.enabled {
color: #212121;
background: #fae2d2;
}

.disabled {
color: #bdbdbd;
background: #f5f5f5;
}

.highlighted {
color: #b75400;
}
25 changes: 16 additions & 9 deletions templates/membership/details-table.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,25 @@ const DetailsTable = ({ data, howItWorksOption }) => {
<article className={styles.content}>
<h3>{data.howItWorks?.title}</h3>
<Markdown>{data.howItWorks?.description}</Markdown>
{data.howItWorks?.action && (
<div className={styles.buttons}>
{data.howItWorks?.actions && (
<Button
href={data.howItWorks?.actions[0].action.url}
variant="outlined"
onClick={toggleVisibleTable}
>
{visibleTable
? data.howItWorks?.actions[0].action.active
: data.howItWorks?.actions[0].action.default}
</Button>
)}
<Button
className={styles.button}
href={data.howItWorks?.action.url}
variant={data.howItWorks?.action.variant || 'outlined'}
onClick={toggleVisibleTable}
href={data.howItWorks?.actions[1].action.url}
variant="contained"
>
{visibleTable
? data.howItWorks?.action.active
: data.howItWorks?.action.default}
{data.howItWorks?.actions[1].action.caption}
</Button>
)}
</div>
</article>
</Section>
) : (
Expand Down
Loading

0 comments on commit 0c1fee1

Please sign in to comment.