Skip to content

Commit

Permalink
code for chapter 3
Browse files Browse the repository at this point in the history
  • Loading branch information
tima101 committed Jul 9, 2019
1 parent bd22c74 commit af51eb4
Show file tree
Hide file tree
Showing 508 changed files with 66,720 additions and 3,550 deletions.
31 changes: 0 additions & 31 deletions app/components/common/AvatarwithMenu.tsx

This file was deleted.

2 changes: 0 additions & 2 deletions app/pages/_document.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { ServerStyleSheets } from '@material-ui/styles';
import Document, { Head, Main, NextScript } from 'next/document';
import React from 'react';
import flush from 'styled-jsx/server';

import { GA_TRACKING_ID } from '../lib/consts';

Expand All @@ -24,7 +23,6 @@ class MyDocument extends Document {
styles: (
<React.Fragment>
{sheets.getStyleElement()}
{flush() || null}
</React.Fragment>
),
};
Expand Down
101 changes: 51 additions & 50 deletions book/10-begin/app/components/common/ActiveLink.tsx
Original file line number Diff line number Diff line change
@@ -1,56 +1,57 @@
import { inject, observer } from 'mobx-react';
import Link from 'next/link';
import { withRouter } from 'next/router';
// 12
// import { inject, observer } from 'mobx-react';
// import Link from 'next/link';
// import { withRouter } from 'next/router';

const ActiveLink = ({ linkText, href, as, hasIcon, highlighterSlug, store }) => {
const selectedElement = store.currentUrl.includes(highlighterSlug);
// const ActiveLink = ({ linkText, href, as, hasIcon, highlighterSlug, store }) => {
// const selectedElement = store.currentUrl.includes(highlighterSlug);

const styleAnchor = {
fontWeight: 400,
fontSize: '14px',
};
// const styleAnchor = {
// fontWeight: 400,
// fontSize: '14px',
// };

const styleAnchorSelectedWithIcon = {
fontWeight: 400,
fontSize: '14px',
position: 'relative',
left: '-14px',
};
// const styleAnchorSelectedWithIcon = {
// fontWeight: 400,
// fontSize: '14px',
// position: 'relative',
// left: '-14px',
// };

const trimmingLength = 20;
// const trimmingLength = 20;

// TODO: solve TS warning
return (
<Link prefetch href={href} as={as}>
<a
// onClick={handleClick}
style={hasIcon && selectedElement ? styleAnchorSelectedWithIcon : styleAnchor}
>
{hasIcon && selectedElement ? (
<i
className="material-icons"
color="action"
style={{
fontSize: 14,
verticalAlign: 'text-bottom',
}}
>
arrow_right
</i>
) : null}
{linkText.length > trimmingLength
? `${linkText.substring(0, trimmingLength)}...`
: linkText}
</a>
</Link>
);
};
// // TODO: solve TS warning
// return (
// <Link prefetch href={href} as={as}>
// <a
// // onClick={handleClick}
// style={hasIcon && selectedElement ? styleAnchorSelectedWithIcon : styleAnchor}
// >
// {hasIcon && selectedElement ? (
// <i
// className="material-icons"
// color="action"
// style={{
// fontSize: 14,
// verticalAlign: 'text-bottom',
// }}
// >
// arrow_right
// </i>
// ) : null}
// {linkText.length > trimmingLength
// ? `${linkText.substring(0, trimmingLength)}...`
// : linkText}
// </a>
// </Link>
// );
// };

export default withRouter<{
linkText?: string;
href?: string;
as?: string;
teamLogo?: string;
hasIcon?: boolean;
highlighterSlug?: string;
}>(inject('store')(observer(ActiveLink)));
// export default withRouter<{
// linkText?: string;
// href?: string;
// as?: string;
// teamLogo?: string;
// hasIcon?: boolean;
// highlighterSlug?: string;
// }>(inject('store')(observer(ActiveLink)));
31 changes: 0 additions & 31 deletions book/10-begin/app/components/common/AvatarwithMenu.tsx

This file was deleted.

2 changes: 0 additions & 2 deletions book/10-begin/app/pages/_document.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { ServerStyleSheets } from '@material-ui/styles';
import Document, { Head, Main, NextScript } from 'next/document';
import React from 'react';
import flush from 'styled-jsx/server';

import { GA_TRACKING_ID } from '../lib/consts';

Expand All @@ -24,7 +23,6 @@ class MyDocument extends Document {
styles: (
<React.Fragment>
{sheets.getStyleElement()}
{flush() || null}
</React.Fragment>
),
};
Expand Down
101 changes: 51 additions & 50 deletions book/10-end/app/components/common/ActiveLink.tsx
Original file line number Diff line number Diff line change
@@ -1,56 +1,57 @@
import { inject, observer } from 'mobx-react';
import Link from 'next/link';
import { withRouter } from 'next/router';
// 12
// import { inject, observer } from 'mobx-react';
// import Link from 'next/link';
// import { withRouter } from 'next/router';

const ActiveLink = ({ linkText, href, as, hasIcon, highlighterSlug, store }) => {
const selectedElement = store.currentUrl.includes(highlighterSlug);
// const ActiveLink = ({ linkText, href, as, hasIcon, highlighterSlug, store }) => {
// const selectedElement = store.currentUrl.includes(highlighterSlug);

const styleAnchor = {
fontWeight: 400,
fontSize: '14px',
};
// const styleAnchor = {
// fontWeight: 400,
// fontSize: '14px',
// };

const styleAnchorSelectedWithIcon = {
fontWeight: 400,
fontSize: '14px',
position: 'relative',
left: '-14px',
};
// const styleAnchorSelectedWithIcon = {
// fontWeight: 400,
// fontSize: '14px',
// position: 'relative',
// left: '-14px',
// };

const trimmingLength = 20;
// const trimmingLength = 20;

// TODO: solve TS warning
return (
<Link prefetch href={href} as={as}>
<a
// onClick={handleClick}
style={hasIcon && selectedElement ? styleAnchorSelectedWithIcon : styleAnchor}
>
{hasIcon && selectedElement ? (
<i
className="material-icons"
color="action"
style={{
fontSize: 14,
verticalAlign: 'text-bottom',
}}
>
arrow_right
</i>
) : null}
{linkText.length > trimmingLength
? `${linkText.substring(0, trimmingLength)}...`
: linkText}
</a>
</Link>
);
};
// // TODO: solve TS warning
// return (
// <Link prefetch href={href} as={as}>
// <a
// // onClick={handleClick}
// style={hasIcon && selectedElement ? styleAnchorSelectedWithIcon : styleAnchor}
// >
// {hasIcon && selectedElement ? (
// <i
// className="material-icons"
// color="action"
// style={{
// fontSize: 14,
// verticalAlign: 'text-bottom',
// }}
// >
// arrow_right
// </i>
// ) : null}
// {linkText.length > trimmingLength
// ? `${linkText.substring(0, trimmingLength)}...`
// : linkText}
// </a>
// </Link>
// );
// };

export default withRouter<{
linkText?: string;
href?: string;
as?: string;
teamLogo?: string;
hasIcon?: boolean;
highlighterSlug?: string;
}>(inject('store')(observer(ActiveLink)));
// export default withRouter<{
// linkText?: string;
// href?: string;
// as?: string;
// teamLogo?: string;
// hasIcon?: boolean;
// highlighterSlug?: string;
// }>(inject('store')(observer(ActiveLink)));
31 changes: 0 additions & 31 deletions book/10-end/app/components/common/AvatarwithMenu.tsx

This file was deleted.

2 changes: 0 additions & 2 deletions book/10-end/app/pages/_document.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { ServerStyleSheets } from '@material-ui/styles';
import Document, { Head, Main, NextScript } from 'next/document';
import React from 'react';
import flush from 'styled-jsx/server';

import { GA_TRACKING_ID } from '../lib/consts';

Expand All @@ -24,7 +23,6 @@ class MyDocument extends Document {
styles: (
<React.Fragment>
{sheets.getStyleElement()}
{flush() || null}
</React.Fragment>
),
};
Expand Down
Loading

0 comments on commit af51eb4

Please sign in to comment.