Commit 23a5ab20 authored by Sam Gluck's avatar Sam Gluck
Browse files

Made a start on folder structure and implementing the Communities

Featured + related components;
parent d9d180d6
......@@ -44,7 +44,7 @@ module.exports = {
appBuild: resolveApp('build'),
appPublic: resolveApp('public'),
appHtml: resolveApp('public/index.html'),
appIndexJs: resolveApp('src/index.js'),
appIndexJs: resolveApp('src/index.tsx'),
appPackageJson: resolveApp('package.json'),
appSrc: resolveApp('src'),
yarnLockFile: resolveApp('yarn.lock'),
......
......@@ -4,8 +4,14 @@
"private": true,
"dependencies": {
"@types/react": "^16.4.14",
"@zendeskgarden/css-avatars": "^3.0.8",
"@zendeskgarden/react-avatars": "^3.0.14",
"@zendeskgarden/react-buttons": "^3.6.2",
"@zendeskgarden/react-chrome": "^4.2.7",
"@zendeskgarden/react-grid": "^1.1.11",
"@zendeskgarden/react-menus": "^3.6.5",
"@zendeskgarden/react-theming": "^3.1.3",
"@zendeskgarden/react-typography": "^0.2.0",
"autoprefixer": "7.1.6",
"awesome-typescript-loader": "3.5.0",
"babel-core": "6.26.0",
......@@ -41,6 +47,7 @@
"react": "^16.5.2",
"react-dev-utils": "^5.0.2",
"react-dom": "^16.5.2",
"react-styleguidist": "^7.3.8",
"resolve": "1.6.0",
"style-loader": "0.19.0",
"styled-components": "^3.4.9",
......@@ -57,12 +64,14 @@
"prettier --single-quote --write",
"git add"
]
},
},
"scripts": {
"start": "node scripts/start.js",
"build": "node scripts/build.js",
"test": "node scripts/test.js --env=jsdom",
"precommit": "lint-staged"
"precommit": "lint-staged",
"test": "node scripts/test.js --env=jsdom",
"styleguide": "styleguidist server",
"styleguide:build": "styleguidist build"
},
"jest": {
"collectCoverageFrom": [
......@@ -108,6 +117,7 @@
},
"devDependencies": {
"@types/node": "^10.10.1",
"eslint-plugin-flowtype": "^2.50.1",
"typescript": "^3.0.3"
}
}
......@@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="theme-color" content="#000000">
<meta name="theme-color" content="#FF7500">
<!--
manifest.json provides metadata used when your web app is added to the
homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/
......@@ -19,7 +19,7 @@
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
<title>MoodleNet</title>
</head>
<body>
<noscript>
......
......@@ -89,7 +89,7 @@ choosePort(HOST, DEFAULT_PORT)
clearConsole();
}
console.log(chalk.cyan('Starting the development server...\n'));
openBrowser(urls.localUrlForBrowser);
// openBrowser(urls.localUrlForBrowser);
});
['SIGINT', 'SIGTERM'].forEach(function(sig) {
......
.App {
text-align: center;
.Body {
padding: 15px;
}
.App-logo {
animation: App-logo-spin infinite 20s linear;
height: 80px;
.Menu {
z-index: 1;
position: fixed;
top: 0;
right: 0;
padding: 15px;
border-left: 1px solid darkgrey;
border-bottom: 1px solid darkgrey;
border-bottom-left-radius: 5px;
background-color: white;
display: flex;
flex-direction: row;
box-shadow: 0 0 3px lightgrey;
}
.App-header {
background-color: orange;
height: 150px;
padding: 20px;
color: white;
.Menu__item:not(:last-child) {
margin-right: 10px;
}
.App-title {
font-size: 1.5em;
.Card {
background-color: white;
padding: 15px;
box-shadow: 0 0 3px lightgrey;
border-radius: 5px;
margin-bottom: 20px;
}
.App-intro {
font-size: large;
}
@keyframes App-logo-spin {
from { transform: rotate(0deg); }
to { transform: rotate(360deg); }
.H1 {
margin: 0 0 30px 0;
}
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
it('renders without crashing', () => {
const div = document.createElement('div');
ReactDOM.render(<App />, div);
ReactDOM.unmountComponentAtNode(div);
});
import * as React from 'react';
const {
Chrome,
Nav,
NavItem,
NavItemText,
Header,
Body,
HeaderItem,
HeaderItemWrapper,
HeaderItemIcon,
HeaderItemText,
} = require('@zendeskgarden/react-chrome')
const logo = require('./logo.svg');
import './App.css';
import '@zendeskgarden/react-chrome/dist/styles.css'
class App extends React.Component {
state: any = {
menuOpen: true
}
toggleMenu () {
this.setState({
menuOpen: !this.state.menuOpen
})
}
render() {
return (
<Chrome className="App">
<Nav expanded={this.state.menuOpen}>
<NavItem logo title="MoodleNet" onClick={() => this.toggleMenu()}>
<NavItemText>MoodleNet</NavItemText>
</NavItem>
<NavItem title="Home">
<NavItemText>Home</NavItemText>
</NavItem>
</Nav>
<Body>
<Header>
<HeaderItem product="support">
<HeaderItemIcon>
<img src={logo} className="App-logo" alt="logo" />
</HeaderItemIcon>
<HeaderItemText>MoodleNet</HeaderItemText>
</HeaderItem>
<HeaderItemWrapper maxX>
<span />
</HeaderItemWrapper>
</Header>
<header className="App-header">
<h1 className="App-title">Welcome to MoodleNet</h1>
</header>
<p className="App-intro">
body content
</p>
</Body>
</Chrome>
);
}
}
export default App;
App example:
```js
<App />
```
import * as React from 'react';
const { Chrome, Body } = require('@zendeskgarden/react-chrome');
const { Nav } = require('../Nav/Nav');
const { Menu } = require('../Menu/Menu');
const {
CommunitiesFeatured
} = require('../../../pages/communities.featured/CommunitiesFeatured');
import '@zendeskgarden/react-chrome/dist/styles.css';
import '@zendeskgarden/react-grid/dist/styles.css';
import '@zendeskgarden/react-buttons/dist/styles.css';
import '@zendeskgarden/react-menus/dist/styles.css';
import '@zendeskgarden/react-avatars/dist/styles.css';
import '../../../App.css';
export class App extends React.Component {
render() {
return (
<Chrome className="App">
<Nav />
<Body className="Body">
<Menu />
<CommunitiesFeatured />
</Body>
</Chrome>
);
}
}
import * as React from 'react';
import { Menu as ZenMenu, Item } from '@zendeskgarden/react-menus';
import { Avatar } from '@zendeskgarden/react-avatars';
const avatar = require('../../../static/img/avatar.png');
const search = require('../../../static/img/search.png');
const notifications = require('../../../static/img/notifications.png');
export const Menu = () => (
<div className="Menu">
<div className="Menu__item">
<ZenMenu
trigger={({ ref }) => (
<img ref={ref} width={30} height={30} src={search} alt="Search" />
)}
>
<Item>1</Item>
<Item>2</Item>
<Item>3</Item>
</ZenMenu>
</div>
<div className="Menu__item">
<ZenMenu
trigger={({ ref }) => (
<img
ref={ref}
width={30}
height={30}
src={notifications}
alt="Notifications"
/>
)}
>
<Item>1</Item>
<Item>2</Item>
<Item>3</Item>
</ZenMenu>
</div>
<div className="Menu__item">
<ZenMenu
trigger={({ ref }) => (
<Avatar innerRef={ref}>
<img src={avatar} alt="Joe Bloggs" />
</Avatar>
)}
>
<Item>Your Profile</Item>
<Item>Settings</Item>
<Item>About MoodleNet</Item>
<Item>Sign out</Item>
</ZenMenu>
</div>
</div>
);
import * as React from 'react';
const {
Nav: ZenNav,
NavItem,
NavItemText,
NavItemIcon,
SubNav,
SubNavItem,
SubNavItemText
} = require('@zendeskgarden/react-chrome');
const logo = require('../../../static/img/moodle-logo.png');
enum NavItems {
Communities,
Collections
}
enum SubNavItems {
Featured,
Yours,
Following
}
const subNavItems = {
[NavItems.Communities]: ({ current }) => (
<>
<SubNavItem current={current === SubNavItems.Featured}>
<SubNavItemText>Featured</SubNavItemText>
</SubNavItem>
<SubNavItem current={current === SubNavItems.Yours}>
<SubNavItemText>Yours</SubNavItemText>
</SubNavItem>
</>
),
[NavItems.Collections]: ({ current }) => (
<>
<SubNavItem current={current === SubNavItems.Featured}>
<SubNavItemText>Featured</SubNavItemText>,
</SubNavItem>
<SubNavItem current={current === SubNavItems.Following}>
<SubNavItemText>Following</SubNavItemText>,
</SubNavItem>
<SubNavItem current={current === SubNavItems.Yours}>
<SubNavItemText>Yours</SubNavItemText>,
</SubNavItem>
</>
)
};
export class Nav extends React.Component {
state: any = {
navOpen: true,
activeNav: NavItems.Communities,
activeSubNav: SubNavItems.Featured
};
toggleMenu() {
this.setState({
navOpen: !this.state.navOpen
});
}
render() {
return (
<>
<ZenNav expanded={this.state.navOpen}>
<NavItem logo title="MoodleNet" onClick={() => this.toggleMenu()}>
<NavItemIcon>
<img src={logo} />
</NavItemIcon>
<NavItemText>MoodleNet</NavItemText>
</NavItem>
<NavItem
title="Communities"
current={this.state.activeNav === NavItems.Communities}
>
<NavItemText>Communities</NavItemText>
</NavItem>
<NavItem
title="Collections"
current={this.state.activeNav === NavItems.Collections}
>
<NavItemText>Collections</NavItemText>
</NavItem>
</ZenNav>
<SubNav>
{...subNavItems[this.state.activeNav]({
current: this.state.activeSubNav
})}
</SubNav>
</>
);
}
}
Button example:
```js
<MoodleButton>Hello world</MoodleButton>
```
import * as React from 'react';
const { ThemeProvider } = require('@zendeskgarden/react-theming');
const { Button } = require('@zendeskgarden/react-buttons');
const { defaultTheme } = require('../../../theme');
const theme = {
'buttons.button': `
background-color: '${defaultTheme.primaryColor}';
color: white;
`
};
export const MoodleButton = ({ children }) => {
return (
<ThemeProvider theme={theme}>
<Button>{children}</Button>
</ThemeProvider>
);
};
import * as React from 'react';
const { H4 } = require('../../typography/H4/H4');
const { MoodleButton } = require('../Button/Button');
export const Card = ({ title }) => (
<div className="Card">
<H4>{title}</H4>
<MoodleButton>View</MoodleButton>
</div>
);
H1 example:
```js
<H1>Hello world</H1>
```
import * as React from 'react';
import { XXL } from '@zendeskgarden/react-typography';
export const H1 = ({ children }) => <XXL className="H1">{children}</XXL>;
H4 example:
```js
<H4>Hello world</H4>
```
import * as React from 'react';
import { MD } from '@zendeskgarden/react-typography';
export const H4 = ({ children }) => <MD className="H4">{children}</MD>;
import React from 'react';
import * as React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import { App } from './components/chrome/App/App';
import registerServiceWorker from './registerServiceWorker';
ReactDOM.render(<App />, document.getElementById('root'));
......
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 841.9 595.3">
<g fill="#61DAFB">
<path d="M666.3 296.5c0-32.5-40.7-63.3-103.1-82.4 14.4-63.6 8-114.2-20.2-130.4-6.5-3.8-14.1-5.6-22.4-5.6v22.3c4.6 0 8.3.9 11.4 2.6 13.6 7.8 19.5 37.5 14.9 75.7-1.1 9.4-2.9 19.3-5.1 29.4-19.6-4.8-41-8.5-63.5-10.9-13.5-18.5-27.5-35.3-41.6-50 32.6-30.3 63.2-46.9 84-46.9V78c-27.5 0-63.5 19.6-99.9 53.6-36.4-33.8-72.4-53.2-99.9-53.2v22.3c20.7 0 51.4 16.5 84 46.6-14 14.7-28 31.4-41.3 49.9-22.6 2.4-44 6.1-63.6 11-2.3-10-4-19.7-5.2-29-4.7-38.2 1.1-67.9 14.6-75.8 3-1.8 6.9-2.6 11.5-2.6V78.5c-8.4 0-16 1.8-22.6 5.6-28.1 16.2-34.4 66.7-19.9 130.1-62.2 19.2-102.7 49.9-102.7 82.3 0 32.5 40.7 63.3 103.1 82.4-14.4 63.6-8 114.2 20.2 130.4 6.5 3.8 14.1 5.6 22.5 5.6 27.5 0 63.5-19.6 99.9-53.6 36.4 33.8 72.4 53.2 99.9 53.2 8.4 0 16-1.8 22.6-5.6 28.1-16.2 34.4-66.7 19.9-130.1 62-19.1 102.5-49.9 102.5-82.3zm-130.2-66.7c-3.7 12.9-8.3 26.2-13.5 39.5-4.1-8-8.4-16-13.1-24-4.6-8-9.5-15.8-14.4-23.4 14.2 2.1 27.9 4.7 41 7.9zm-45.8 106.5c-7.8 13.5-15.8 26.3-24.1 38.2-14.9 1.3-30 2-45.2 2-15.1 0-30.2-.7-45-1.9-8.3-11.9-16.4-24.6-24.2-38-7.6-13.1-14.5-26.4-20.8-39.8 6.2-13.4 13.2-26.8 20.7-39.9 7.8-13.5 15.8-26.3 24.1-38.2 14.9-1.3 30-2 45.2-2 15.1 0 30.2.7 45 1.9 8.3 11.9 16.4 24.6 24.2 38 7.6 13.1 14.5 26.4 20.8 39.8-6.3 13.4-13.2 26.8-20.7 39.9zm32.3-13c5.4 13.4 10 26.8 13.8 39.8-13.1 3.2-26.9 5.9-41.2 8 4.9-7.7 9.8-15.6 14.4-23.7 4.6-8 8.9-16.1 13-24.1zM421.2 430c-9.3-9.6-18.6-20.3-27.8-32 9 .4 18.2.7 27.5.7 9.4 0 18.7-.2 27.8-.7-9 11.7-18.3 22.4-27.5 32zm-74.4-58.9c-14.2-2.1-27.9-4.7-41-7.9 3.7-12.9 8.3-26.2 13.5-39.5 4.1 8 8.4 16 13.1 24 4.7 8 9.5 15.8 14.4 23.4zM420.7 163c9.3 9.6 18.6 20.3 27.8 32-9-.4-18.2-.7-27.5-.7-9.4 0-18.7.2-27.8.7 9-11.7 18.3-22.4 27.5-32zm-74 58.9c-4.9 7.7-9.8 15.6-14.4 23.7-4.6 8-8.9 16-13 24-5.4-13.4-10-26.8-13.8-39.8 13.1-3.1 26.9-5.8 41.2-7.9zm-90.5 125.2c-35.4-15.1-58.3-34.9-58.3-50.6 0-15.7 22.9-35.6 58.3-50.6 8.6-3.7 18-7 27.7-10.1 5.7 19.6 13.2 40 22.5 60.9-9.2 20.8-16.6 41.1-22.2 60.6-9.9-3.1-19.3-6.5-28-10.2zM310 490c-13.6-7.8-19.5-37.5-14.9-75.7 1.1-9.4 2.9-19.3 5.1-29.4 19.6 4.8 41 8.5 63.5 10.9 13.5 18.5 27.5 35.3 41.6 50-32.6 30.3-63.2 46.9-84 46.9-4.5-.1-8.3-1-11.3-2.7zm237.2-76.2c4.7 38.2-1.1 67.9-14.6 75.8-3 1.8-6.9 2.6-11.5 2.6-20.7 0-51.4-16.5-84-46.6 14-14.7 28-31.4 41.3-49.9 22.6-2.4 44-6.1 63.6-11 2.3 10.1 4.1 19.8 5.2 29.1zm38.5-66.7c-8.6 3.7-18 7-27.7 10.1-5.7-19.6-13.2-40-22.5-60.9 9.2-20.8 16.6-41.1 22.2-60.6 9.9 3.1 19.3 6.5 28.1 10.2 35.4 15.1 58.3 34.9 58.3 50.6-.1 15.7-23 35.6-58.4 50.6zM320.8 78.4z"/>
<circle cx="420.9" cy="296.5" r="45.7"/>
<path d="M520.5 78.1z"/>
</g>
</svg>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment