Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Expiration Date" feature for Community Hero and Events #1281

Merged
merged 58 commits into from
May 15, 2020
Merged
Show file tree
Hide file tree
Changes from 53 commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
a09c23b
Skip rendering events if none are in the future.
rogermparent May 11, 2020
47624bf
Merge branch 'master' into invalidate-old-events
rogermparent May 11, 2020
bbb7ab5
Add moment.js to dependencies and run yarn upgrade
rogermparent May 11, 2020
4154e14
Add support for community page expiration dates
rogermparent May 11, 2020
af3de1b
Add an expiration date to the current Hero data
rogermparent May 11, 2020
4f5651c
Merge branch 'master' into invalidate-old-events
rogermparent May 11, 2020
d3612a0
new header
elleobrien May 11, 2020
b032390
Create Community/Events and JsonFile models
rogermparent May 11, 2020
ce8a14b
white background header
elleobrien May 11, 2020
129e6ac
skinny header
elleobrien May 12, 2020
8c4524c
Move Community data into GraphQL
rogermparent May 12, 2020
0b7d19b
Change Community Hero link to fragment
rogermparent May 12, 2020
4d819d3
mobile banner skinny
elleobrien May 12, 2020
a186a10
mobile header skinny
elleobrien May 12, 2020
a5b5dca
Add Hero from the header branch as a non-expiring fallback.
rogermparent May 12, 2020
8cb6f65
Merge branch 'master' into invalidate-old-events
rogermparent May 12, 2020
50ccc4a
remove border on mobile
elleobrien May 12, 2020
bbdf2f8
no border for real
elleobrien May 12, 2020
782aa59
Merge branch 'master' of https://github.com/iterative/dvc.org into he…
elleobrien May 12, 2020
4a503a9
update user generated content links
elleobrien May 12, 2020
967d908
update ambassador link
elleobrien May 12, 2020
2810198
Create, export, and import interfaces to fix TS issues
rogermparent May 12, 2020
b319eb7
Revert global CSS smooth scrolling
rogermparent May 12, 2020
05fb697
Change DVC Ambassador link to root-relative _self
rogermparent May 12, 2020
b4cb7b6
Delete banner-mobile.png
elleobrien May 12, 2020
4fe1088
Delete banner.png
elleobrien May 12, 2020
b5f7ad9
Delete fowler_icon.ico
elleobrien May 12, 2020
bd9ebbc
Delete ml-axis-of-change.png
elleobrien May 12, 2020
66d056e
Delete donuts.png
elleobrien May 12, 2020
2966195
Add smooth scrolling to local fragment Hero
rogermparent May 13, 2020
90a9312
Merge branch 'header' of https://github.com/iterative/dvc.org into he…
rogermparent May 13, 2020
3d8a65a
Fix TS issues
rogermparent May 13, 2020
dca3785
Remove duration option which broke animation
rogermparent May 13, 2020
b236661
Merge new header into new data schema
rogermparent May 13, 2020
72c6c19
Change false string to literal false in community.json
rogermparent May 13, 2020
0ef0275
Improve and fix schema
rogermparent May 13, 2020
b430d11
move marcel pic
elleobrien May 13, 2020
3c214cc
Merge branch 'header' of https://github.com/iterative/dvc.org into he…
elleobrien May 13, 2020
1004703
Integrate smooth scroll into regular link component
rogermparent May 13, 2020
7e193bf
Merge branch 'header' of https://github.com/iterative/dvc.org into in…
rogermparent May 13, 2020
7cb4b26
Rename default banner images to a more generic name
rogermparent May 13, 2020
ce2fe14
Merge updated master 5/13
rogermparent May 13, 2020
47f5571
remove unused import from community model
rogermparent May 13, 2020
5a64f10
Fix unrelated unused imports
rogermparent May 13, 2020
0519cbe
Fix handling of 0 usable events
rogermparent May 13, 2020
59a65ca
Merge branch 'master' into invalidate-old-events
rogermparent May 13, 2020
7aa48e7
fix TS issues
rogermparent May 13, 2020
763e6bf
Fix link in community JSON data
rogermparent May 13, 2020
c08e73a
Remove TODO
rogermparent May 14, 2020
0ab1918
Change "Women in San Diego" event date
rogermparent May 14, 2020
aafa73a
Display a message in a situation with no events.
rogermparent May 14, 2020
e9a7f1b
Simplify getExpirationDate
rogermparent May 14, 2020
7e470ea
Explicitly define sourceIndex on Hero items
rogermparent May 14, 2020
8b1eda7
Change events placeholder to use a common "gray text" class
rogermparent May 14, 2020
2ab77f1
Write tests for Expiration helpers
rogermparent May 15, 2020
502ce09
Fix a typo in Event css
rogermparent May 15, 2020
395dad4
Change shared gray text class to be named "gray"
rogermparent May 15, 2020
57d21c7
Merge branch 'master' of https://github.com/iterative/dvc.org into in…
rogermparent May 15, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions src/components/Community/data.json → content/community.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
{
"hero": {
"pictureDesktop": "/img/community/header_mailing_list_skinny.png",
"pictureMobile": "/img/community/mobile_header_mailing_list_skinny.png",
"url": "#subscribe"
},
"hero": [
{
"pictureDesktop": "/img/community/default-banner.png",
"pictureMobile": "/img/community/default-mobile-banner.png",
"url": "#subscribe",
"expires": false
}
],
"section": {
"contribute": {
"title": "Contribute",
Expand Down Expand Up @@ -52,7 +55,7 @@
"pictureUrl": "/img/community/ugc/medium_logo.png"
},
{
"url": "https://blog.codecentric.de/en/2020/01/remote-training-gitlab-ci-dvc/",
"url": "https://mribeirodantas.xyz/blog/index.php/2020/03/05/r-dvc-and-rmarkdown/",
shcheklein marked this conversation as resolved.
Show resolved Hide resolved
rogermparent marked this conversation as resolved.
Show resolved Hide resolved
"title": "Manage your Data Science Project in R",
"author": "Marcel Ribeiro-Dantas",
"date": "2020-03-05",
Expand All @@ -72,7 +75,7 @@
"title": "Women in Data Science San Diego",
"description": "Elle O'Brien is talking about data catalogs and feature stores.",
"city": "San Diego",
"date": "2020-05-10"
"date": "2020-03-27"
},
{
"url": "https://www.mlprague.com/#schedule-saturday",
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"iso-url": "^0.4.7",
"isomorphic-fetch": "^2.2.1",
"lodash": "^4.17.15",
"moment": "^2.25.3",
"nanoid": "^3.0.2",
"node-cache": "^5.1.0",
"perfect-scrollbar": "^1.5.0",
Expand Down
3 changes: 0 additions & 3 deletions scripts/deploy-with-s3.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
'use strict'
require('dotenv').config()
const path = require('path')
const crypto = require('crypto')
const PRODUCTION_PREFIX = 'dvc-org-prod'

const { DEPLOY_OPTIONS } = process.env
Expand Down Expand Up @@ -61,8 +60,6 @@ const cacheDirs = [
['.cache', '-cache/']
]

const fs = require('fs')
rogermparent marked this conversation as resolved.
Show resolved Hide resolved

const { s3Prefix, withEntries, prefixIsEmpty } = require('./s3-utils')
const { move } = require('fs-extra')
const { downloadAllFromS3, uploadAllToS3, cleanAllLocal } = withEntries(
Expand Down
2 changes: 1 addition & 1 deletion scripts/s3-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const path = require('path')
const s3 = require('s3-client')
const { s3Prefix, s3Bucket } = require('../src/server/config')
const { remove, move, ensureDir } = require('fs-extra')
rogermparent marked this conversation as resolved.
Show resolved Hide resolved
const { remove, ensureDir } = require('fs-extra')

const {
AWS_REGION,
Expand Down
12 changes: 9 additions & 3 deletions src/components/Community/Contribute/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,23 @@ import CommunityBlock from '../Block'
import CommunitySection from '../Section'
import { logEvent } from '../../../utils/front/ga'

import data from '../data.json'
import { useCommunityData } from '../../../utils/front/community'
import sharedStyles from '../styles.module.css'

const { description, mobileDescription, title } = data.section.contribute

const logPR = (): void => logEvent('community', 'contribute-pr')
const logBlogpost = (): void => logEvent('community', 'contribute-blogpost')
const logTalk = (): void => logEvent('community', 'contribute-talk')
const logAmbassador = (): void => logEvent('community', 'contribute-ambassador')

const Contribute: React.FC<{ theme: ICommunitySectionTheme }> = ({ theme }) => {
const {
rest: {
section: {
contribute: { description, mobileDescription, title }
}
}
} = useCommunityData()

return (
<LayoutWidthContainer className={sharedStyles.wrapper}>
<CommunitySection
Expand Down
45 changes: 23 additions & 22 deletions src/components/Community/Events/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import Link from '../../Link'
import Block from '../Block'
import Section from '../Section'
import { logEvent } from '../../../utils/front/ga'
import { useCommunityData } from '../../../utils/front/community'

import data from '../data.json'
import sharedStyles from '../styles.module.css'
import styles from './styles.module.css'

interface IEvent {
export interface IEvent {
theme: ICommunitySectionTheme
city: string
date: string
Expand All @@ -23,19 +23,6 @@ interface IEvent {
url: string
}

const { description, mobileDescription, title } = data.section.events
const { events } = data
const eventsItems = ((): Array<IEvent | null> => {
const items: Array<IEvent | null> = events.slice(0, 3) as Array<IEvent>
const itemLength = items.length

for (let i = itemLength; i < 3; i++) {
items.push(null)
}

return items
})()

const Event: React.FC<IEvent> = ({
theme,
city,
Expand Down Expand Up @@ -97,9 +84,14 @@ const Event: React.FC<IEvent> = ({
}

const Events: React.FC<{ theme: ICommunitySectionTheme }> = ({ theme }) => {
if (!events.length) {
return null
}
const {
events,
rest: {
section: {
events: { description, mobileDescription, title }
}
}
} = useCommunityData()

return (
<LayoutWidthContainer className={sharedStyles.wrapper}>
Expand All @@ -112,11 +104,20 @@ const Events: React.FC<{ theme: ICommunitySectionTheme }> = ({ theme }) => {
title={title}
>
<div className={sharedStyles.items}>
{eventsItems.map((event, key) => (
<div className={sharedStyles.item} key={key}>
{event && <Event {...event} theme={theme} key={event.url} />}
{events ? (
events.map((event, key) => (
<div className={sharedStyles.item} key={key}>
{event && <Event {...event} theme={theme} key={event.url} />}
</div>
))
) : (
<div className={styles.eventsPlaceholder}>
rogermparent marked this conversation as resolved.
Show resolved Hide resolved
No upcoming events. Subscribe to be up to date!{' '}
<span role="img" aria-label="Subscribe below">
👇
</span>
</div>
))}
)}
</div>
</Section>
</LayoutWidthContainer>
Expand Down
10 changes: 10 additions & 0 deletions src/components/Community/Events/styles.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,13 @@
display: block;
margin: -10px -20px 0;
}

.eventsPlaceholder {
text-align: center;
margin: auto;
font-size: 1rem;

@media screen and (min-width: 480px) {
font-size: 1.25rem;
}
}
59 changes: 20 additions & 39 deletions src/components/Community/Hero/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,63 +2,44 @@ import React from 'react'

import LayoutWidthContainer from '../../LayoutWidthContainer'
import ShowOnly from '../../ShowOnly'
import Link, { ILinkProps } from '../../Link'
import Link from '../../Link'
import { useCommunityData } from '../../../utils/front/community'
import { logEvent } from '../../../utils/front/ga'
import { scrollIntoLayout } from '../../../utils/front/scroll'

import data from '../data.json'
import styles from './styles.module.css'

const logHero = (): void => logEvent('community', 'hero')

// This special link component will smooth-scroll on local fragment links
const MaybeSmoothLink: React.FC<ILinkProps> = props => {
const { href, children } = props
if (href.startsWith('#')) {
// Intercept local fragment links and turn them into a special
// smooth-scrolling `a` element
return (
<Link
{...props}
onClick={(): void => {
logHero()
scrollIntoLayout(document.getElementById(href.slice(1)), {
smooth: true
})
}}
>
{children}
</Link>
)
} else {
// Pass through all props to a normal link otherwise
return <Link {...props} />
}
export interface IHero {
url: string
pictureDesktop: string
pictureMobile: string
}

const Hero: React.FC = () => {
if (!data.hero) {
const { hero } = useCommunityData()

if (!hero) {
return null
}

return (
<LayoutWidthContainer className={styles.container}>
<MaybeSmoothLink className={styles.link} href={data.hero.url}>
<Link
className={styles.link}
href={hero.url}
onClick={logHero}
scrollOptions={{
smooth: true
}}
>
<ShowOnly on="desktop">
<img
className={styles.picture}
src={data.hero.pictureDesktop}
alt=""
/>
<img className={styles.picture} src={hero.pictureDesktop} alt="" />
</ShowOnly>
<ShowOnly on="mobile">
<img
className={styles.picture}
src={data.hero.pictureMobile}
alt=""
/>
<img className={styles.picture} src={hero.pictureMobile} alt="" />
</ShowOnly>
</MaybeSmoothLink>
</Link>
</LayoutWidthContainer>
)
}
Expand Down
17 changes: 12 additions & 5 deletions src/components/Community/Learn/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,14 @@ import Section from '../Section'
import { logEvent } from '../../../utils/front/ga'
import { getFirstPage } from '../../../utils/shared/sidebar'
import { useCommentsCount } from '../../../utils/front/api'
import { useCommunityData } from '../../../utils/front/community'
import getPosts from '../../../queries/posts'
import { pluralizeComments } from '../../../utils/front/i18n'

import data from '../data.json'
import sharedStyles from '../styles.module.css'
import styles from './styles.module.css'

const docsPage = getFirstPage()
const { description, mobileDescription, title } = data.section.learn
const { documentation, userContent } = data

const logPostAll = (): void => logEvent('community', 'blog', 'all')
const logDocumentationAll = (): void =>
Expand Down Expand Up @@ -92,7 +90,7 @@ const BlogPost: React.FC<ICommunityBlogPost> = ({
)
}

interface ICommunityUserContentProps {
export interface ICommunityUserContentProps {
author: string
color: string
date: string
Expand Down Expand Up @@ -147,7 +145,7 @@ const UserContent: React.FC<ICommunityUserContentProps> = ({
)
}

interface ICommunityDocumentationProps {
export interface ICommunityDocumentationProps {
color: string
description: string
title: string
Expand Down Expand Up @@ -182,6 +180,15 @@ const Documentation: React.FC<ICommunityDocumentationProps> = ({

const Learn: React.FC<{ theme: ICommunitySectionTheme }> = ({ theme }) => {
const posts = getPosts()
const {
rest: {
documentation,
userContent,
section: {
learn: { description, mobileDescription, title }
}
}
} = useCommunityData()

return (
<LayoutWidthContainer className={sharedStyles.wrapper}>
Expand Down
5 changes: 3 additions & 2 deletions src/components/Community/Meet/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@ import {
IDiscussTopic
} from '../../../utils/front/api'

import data from '../data.json'
import { useCommunityData } from '../../../utils/front/community'
import sharedStyles from '../styles.module.css'
import styles from './styles.module.css'

const { description, mobileDescription, title } = data.section.meet
const logIssueAll = (): void => logEvent('community', 'issue', 'all')
const logTopicAll = (): void => logEvent('community', 'topic', 'all')
const logDiscord = (): void => logEvent('community', 'discord')
Expand Down Expand Up @@ -99,6 +98,8 @@ const Issue: React.FC<{ color: string } & IGithubIssue> = ({
}

const Meet: React.FC<{ theme: ICommunitySectionTheme }> = ({ theme }) => {
const data = useCommunityData().rest
const { description, mobileDescription, title } = data.section.meet
const { error: issuesError, ready: issuesReady, result: issues } = useIssues()
const { error: topicsError, ready: topicsReady, result: topics } = useTopics()

Expand Down
2 changes: 1 addition & 1 deletion src/components/Community/Section/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { screens } from '../../../../config/postcss/media'

import styles from './styles.module.css'

interface ICommunitySection {
export interface ICommunitySection {
anchor: string
background?: string
color: string
Expand Down
Loading