Skip to content
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
fb26b91
base chiclet page
natalieethell Apr 6, 2018
ad94997
moving Chiclet to experiments
natalieethell Apr 16, 2018
542fcf8
other changes to old chiclet
natalieethell Apr 16, 2018
c6f0aab
basic chiclet moved to experiments
natalieethell Apr 19, 2018
5d7f668
get rid of chiclet references in old directory
natalieethell Apr 19, 2018
56f52c9
get rid of last Chiclet reference in wrong directory
natalieethell Apr 19, 2018
15ccf73
added icons and started cleaning up
natalieethell Apr 19, 2018
1012e4c
almost fixed hover border
natalieethell Apr 19, 2018
ee82f29
can choose chiclet size to render and cleanup
natalieethell Apr 19, 2018
fd42f49
three layers of the Chiclet
natalieethell Apr 20, 2018
fc90f50
actions can now be passed in as strings
natalieethell Apr 20, 2018
3fa9d9e
Chiclet -> BaseChiclet, ChicletPicker -> Chiclet
natalieethell Apr 20, 2018
3df9860
ChicletPicker to Chiclet
natalieethell Apr 23, 2018
a2b0fa5
styles sheet working
natalieethell Apr 24, 2018
2e5978d
styling moved to styles sheet
natalieethell Apr 24, 2018
e497323
remove references to scss file
natalieethell Apr 24, 2018
d0b31a2
remove Chiclet.scss and XSmall
natalieethell Apr 25, 2018
d3a9f0d
use ChicletType for type safety
natalieethell Apr 25, 2018
acbcbc2
imageAlt
natalieethell Apr 25, 2018
26cb7d0
added imageAlt to getOpenGraphValues
natalieethell Apr 25, 2018
bbacc49
change onKeyDown to only handle enter, as space is handled by onClick
natalieethell Apr 25, 2018
600e4c8
separated types file out and other small fixes
natalieethell Apr 26, 2018
7742c47
styling cleanup (IChicletCardStyles)
natalieethell Apr 26, 2018
2f3ca5b
remove Chiclet from fabric site, only needs to be in experiments
natalieethell Apr 27, 2018
4e44852
get rid of unnecessary dependencies
natalieethell Apr 27, 2018
64af2e7
do not need ChicletComponentPage on main site
natalieethell Apr 27, 2018
5b4d21d
more cleanup with onClick and ChicletSize
natalieethell Apr 27, 2018
4e87878
separate out opengraph functions
natalieethell Apr 27, 2018
b9581b7
created IChicletAction
natalieethell Apr 27, 2018
3719108
cleanup
natalieethell Apr 27, 2018
7d1104d
styling fixes
natalieethell Apr 30, 2018
f873b97
Merge branch 'master' into chiclet
natalieethell May 1, 2018
5020b32
base files added for BaseChiclet and ChicletCard
natalieethell May 2, 2018
eb3b959
added Chiclet.base
natalieethell May 2, 2018
a44db3b
extract actions from Chiclet and just show a footer
natalieethell May 9, 2018
4ba3924
small fixes: added comments, changed enum, removed placeholders
natalieethell May 10, 2018
65fba98
change breadcrumb to more icon in example
natalieethell May 10, 2018
2b65727
fixed parser and other small fixes
natalieethell May 10, 2018
3965f9a
ogType to openGraphType
natalieethell May 10, 2018
c91dfe3
example with activities
natalieethell May 11, 2018
806aff1
add Chiclet to index
natalieethell May 11, 2018
cbe9c0f
small styling fixes
natalieethell May 11, 2018
eba2185
Breadcrumb description example
natalieethell May 15, 2018
00c9ca3
separate out examples
natalieethell May 15, 2018
6d762d2
nicer icons and defaultProps for file preview image
natalieethell May 15, 2018
7a35619
added properties table
natalieethell May 15, 2018
db18be7
fixed preview image
natalieethell May 15, 2018
02849e3
change file
natalieethell May 16, 2018
ada5ffe
just pass in a Breadcrumb component and breadcrumb styling fixes
natalieethell May 16, 2018
9a1b9c6
openGraphType to itemType, remove old comments, and other cleanup
natalieethell May 16, 2018
4756ed0
rename Chiclet
natalieethell May 16, 2018
a0d6e73
fix merge conflicts
natalieethell May 16, 2018
68b9102
remove unnecessary newline
natalieethell May 16, 2018
1abe186
actually fix merge conflicts
natalieethell May 17, 2018
d353ed7
extractMetaTags to getOpenGraphProperties
natalieethell May 17, 2018
6bad6f0
add return type to getOpenGraphProperties
natalieethell May 17, 2018
49c756b
Merge branch 'master' into chiclet
natalieethell May 17, 2018
972d37d
fixed errors from npm run build
natalieethell May 18, 2018
16156a8
removed unnecessary whitespace change
natalieethell May 18, 2018
275bbc2
snapshot test
natalieethell May 18, 2018
db80bf2
better description for snapshot test
natalieethell May 18, 2018
70badd3
small fix for preview image
natalieethell May 18, 2018
5b381fb
change preview image link to sharepoint link
natalieethell May 18, 2018
8f17013
change file for Chiclet
natalieethell May 18, 2018
9a7d9e8
fixed tslint errors and added state to Chiclet
natalieethell May 21, 2018
be9118f
small bug fix for image preview and change sample url
natalieethell May 21, 2018
b33c5b8
numerical pixel values represented as numbers rather than strings
natalieethell May 21, 2018
51f1ba8
removed unnecessary styling names
natalieethell May 21, 2018
679e0a6
description and footer now JSX.Elements
natalieethell May 21, 2018
c404200
removed unnecessary styling from Chiclet and updated snapshot
natalieethell May 21, 2018
7a550dc
Merge branch 'master' into chiclet
natalieethell May 21, 2018
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
6 changes: 6 additions & 0 deletions apps/fabric-website/src/components/App/AppState.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,12 @@ export const AppState: IAppState = {
component: () => <LoadingComponent title='Coachmark' />,
getComponent: cb => require.ensure([], (require) => cb(require<any>('../../pages/Components/CoachmarkComponentPage').CoachmarkComponentPage))
},
{

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add the demo page to office-ui-fabric-react/packages/experiments/src/demo/AppDefinition.tsx instead, as the Chiclet will be in experiments.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can follow the example of TilesListPage of any other existing component in experiments

title: 'Chiclet',
url: '#/components/chiclet',
component: () => <LoadingComponent title='Chiclet' />,
getComponent: cb => require.ensure([], (require) => cb(require<any>('../../pages/Components/ChicletComponentPage').ChicletComponentPage))
},
{
title: 'ChoiceGroup',
url: '#/components/choicegroup',
Expand Down
38 changes: 38 additions & 0 deletions apps/fabric-website/src/pages/Components/ChicletComponentPage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import * as React from 'react';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move this page under experiments

import { ChicletPage } from 'office-ui-fabric-react/lib/components/Chiclet/ChicletPage';
import { PageHeader } from '../../components/PageHeader/PageHeader';
import { ComponentPage } from '../../components/ComponentPage/ComponentPage';
const pageStyles: any = require('../PageStyles.module.scss');

export class ChicletComponentPage extends React.Component<any, any> {
public render() {
return (
<div ref='pageElement' className={ pageStyles.basePage }>
<ComponentPage>
<PageHeader pageTitle='Chiclet' backgroundColor='#038387'
links={
[
{
'text': 'Overview',
'location': 'Overview'
},
{
'text': 'Best Practices',
'location': 'BestPractices'
},
{
'text': 'Variants',
'location': 'Variants'
},
{
'text': 'Implementation',
'location': 'Implementation'
}
]
} />
<ChicletPage isHeaderVisible={ false } />
</ComponentPage>
</div>
);
}
}
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,11 @@
"license": "MIT",
"devDependencies": {
"@microsoft/rush": "4.3.0"
},
"dependencies": {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don;t need these anymore, right?

"@types/cheerio": "^0.22.7",
"@types/htmlparser2": "^3.7.31",
"htmlparser": "^1.7.7",
"htmlparser2": "^3.9.2"
}
}
5 changes: 5 additions & 0 deletions packages/experiments/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" user-scalable="no" />
<meta property="og:title" content="WordTest with a really long title that will wrap around to the second line but not the third line">
<meta property="og:type" content="word">
<meta property="og:description" content="This is a test Word document for our Chiclet">
<meta property="og:url" content="https://1drv.ms/w/s!AuT_wMavg6p-gSs6utwJnX-Thtbpvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv">
<meta property="og:image" content="https://i.ytimg.com/vi/MmKlaGpmYig/maxresdefault.jpg">

<title>Office UI Fabric React Examples</title>

Expand Down
1 change: 1 addition & 0 deletions packages/experiments/src/Chiclet.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './components/Chiclet/index';
5 changes: 5 additions & 0 deletions packages/experiments/src/common/TestImages.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const baseProductionCdnUrl = 'https://az742526.vo.msecnd.net/files/odsp-next-release-odc_2018-04-13_20180418.001/odsp-media/images/apps/';

export const ChicletTestImages = {
iconWordDoc: baseProductionCdnUrl + 'word_16x1.svg',
};
73 changes: 73 additions & 0 deletions packages/experiments/src/components/Chiclet/BaseChiclet.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import * as React from 'react';
import {
BaseComponent,
css
} from '../../Utilities';
import { ChicletCard } from './ChicletCard';
import { Chiclet } from './Chiclet';
import { IBaseChicletProps, IChicletCardProps } from './Chiclet.types';
import { IconButton, IButtonProps } from 'office-ui-fabric-react/lib/Button';

export class BaseChiclet extends BaseComponent<IBaseChicletProps, any> {
public render() {
const { url, size, actions } = this.props;

let chicletCardProps = this.extractMetaTags(url);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious to see what others think here being relatively new to React. Do we want to be fetching these attributes on render? And if so is XMLHttpRequest preferred? Leaving a comment so I can follow-up for my own learning.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we need to fetch, perhaps componentDidMount is better? Honestly need to defer to the rest of the team here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I'm also interested to hear what other people think!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1.Let's add it to componentWillReceiveProps and put the results in state, so we get to recompute if and only if the input url changes


return (
<Chiclet chicletCardProps={ chicletCardProps } size={ size ? size : "medium" } actions={ actions } />

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned elsewhere can prob use Enum value here for type safety

);
}

public extractMetaTags(url: string) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd put this one and the next method in a separate OpenGraph.ts file as static methods.

var attributes: IChicletCardProps = {};

var xmlHttp = new XMLHttpRequest();
xmlHttp.open("GET", url, false);
xmlHttp.overrideMimeType('text/xml');
xmlHttp.send(null);

var metaElements = document.getElementsByTagName("meta");
let openGraphObject = this._getOpenGraphValues(metaElements, attributes);

return openGraphObject;
}

public _getOpenGraphValues(metaElements: NodeListOf<HTMLMetaElement>, attributes: IChicletCardProps): IChicletCardProps {
for (var i = 0; i < metaElements.length; i++) {
if (metaElements[i].attributes != null && metaElements[i].attributes.length >= 2) {
switch (metaElements[i].attributes[0].nodeValue) {
case "og:title":
attributes.title = metaElements[i].content;
break;
case "og:type":
attributes.ogType = metaElements[i].content;
break;
case "og:image":
case "og:image:url":
attributes.image = metaElements[i].content;
break;
case "og:image:secure_url":
attributes.imageSecureUrl = metaElements[i].content;
break;
case "og:image:type":
attributes.imageType = metaElements[i].content;
break;
case "og:image:width":
attributes.imageWidth = metaElements[i].content;
break;
case "og:image:height":
attributes.imageHeight = metaElements[i].content;
break;
case "og:description":
attributes.description = metaElements[i].content;
break;
case "og:url":
attributes.url = metaElements[i].content;
break;
}
}
}
return attributes;
}
}
118 changes: 118 additions & 0 deletions packages/experiments/src/components/Chiclet/Chiclet.styles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
import { memoizeFunction } from '../../Utilities';
import {
mergeStyleSets,
IStyle,
ITheme,
concatStyleSets,
getTheme
} from '../../Styling';
import { IChicletStyles } from './Chiclet.types';

const ChicletCardTitleLineHeight = '21px';

/* Actions */
const msChicletCardActionsActionSize = '34px';
const msChicletCardActionsHorizontalPadding = '12px';
const msChicletCardActionsVerticalPadding = '2px';

export const getClassNames = memoizeFunction((

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please avoid using memoizeFunction and getClassNames. Instead, use styled helper and the getStyles prop to make things style-able.

Follow the guidance here:

https://github.com/OfficeDev/office-ui-fabric-react/blob/master/ghdocs/BestPractices/Styling.md

theme: ITheme = getTheme(),
customStyles?: IChicletStyles
): IChicletStyles => {
const styles: IChicletStyles = {
root: {
WebkitFontSmoothing: 'antialiased',
backgroundColor: 'white',
border: `1px solid ${theme.palette.neutralLight}`,
boxSizing: 'border-box',
maxWidth: '320px',
minWidth: '540px',
height: '109px',
userSelect: 'none',
position: 'relative',
selectors: {
':hover': {
cursor: 'pointer',
border: `1px solid ${theme.palette.neutralTertiaryAlt}`
}
}
},
icon: [
'ms-DocumentCardPreview-icon',
{
marginLeft: '10px',
bottom: '10px',
position: 'absolute',
color: '#166EBE'
}
],
preview: [
'ms-ChicletCardPreview',
{
float: 'left',
maxHeight: '107px',
maxWidth: '160px',
position: 'relative',
overflow: 'hidden', // need to fix
backgroundColor: theme.palette.neutralLighterAlt,
display: 'block'
}
],
info: [
'ms-ChicletCardInfo',
{
position: 'relative',
display: 'block',
height: '100%',
lineHeight: '21px',
overflow: 'hidden',
wordWrap: 'break-word'
}
],
title: [
'ms-ChicletCardTitle',
{
padding: '8px 16px 0px',
font: theme.fonts.large,
color: theme.palette.neutralPrimary,
height: '42px', // Two lines of text, making sure the third line is hidden
lineHeight: ChicletCardTitleLineHeight,
overflow: 'hidden',
wordWrap: 'break-word',
fontWeight: '400'
}
],
link: [
'ms-ChicletCardLink',
{
padding: '4px 16px 0px',
fontSize: '8pt',
color: theme.palette.neutralTertiaryAlt,
lineHeight: '14px',
height: '14px',
overflow: 'hidden',
whiteSpace: 'nowrap',
textOverflow: 'ellipsis'
}
],
actions: [
'ms-ChicletFooter',
{
height: msChicletCardActionsActionSize,
padding: `${msChicletCardActionsVerticalPadding} ${msChicletCardActionsHorizontalPadding}`,
position: 'relative'
}
],
action: [
'ms-ChicletFooter-action',
{
float: 'right',
marginLeft: '4px',
cursor: 'pointer'
}
]
};

return concatStyleSets(styles, customStyles)!;

});
64 changes: 64 additions & 0 deletions packages/experiments/src/components/Chiclet/Chiclet.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import * as React from 'react';
import {
css
} from '../../Utilities';
import {
getClassNames
} from './Chiclet.styles';
import { IChicletProps, IChicletCardProps, IChicletStyles } from './Chiclet.types';
import { mergeStyles } from '../../Styling';
import { ChicletCard } from './ChicletCard';
import { IButtonProps } from 'office-ui-fabric-react/lib/Button';

export class Chiclet extends React.Component<IChicletProps, IChicletCardProps> {
private _classNames: IChicletStyles = {};

public render() {
const { styles: customStyles, chicletCardProps, size, actions, theme } = this.props;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can probably add { ... onClick = _onClick ... } = this.props; and remove it from the manual DOM assignment below. I think we do it across the lib for functions that can be supplied via props including event handlers (tho this link isn't an event handler example): https://github.com/OfficeDev/office-ui-fabric-react/blob/fee79fb9e115dd282a4337418ac77ed4f1c6cad7/packages/office-ui-fabric-react/src/components/TextField/TextField.tsx#L150

this._classNames = getClassNames(theme!, customStyles);

var actionsToIButtonProps: IButtonProps[] = [];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest let's add the actions when we get there, or put some more thought to this. Each action will possibly need to contain more information, like at least an onClick handler. We could have something like:
actions?: IChicletAction[];

interface IChicletAction {
iconName: string; // or iconProps
onClick: (ev) => void;
}

if (actions != null) {
actions.forEach(function (string) {
switch (string) {
case "Breadcrumb":
actionsToIButtonProps.push({ iconProps: { iconName: 'Breadcrumb' } });
break;
case "Save":
actionsToIButtonProps.push({ iconProps: { iconName: 'Save' } });
break;
case "Share":
actionsToIButtonProps.push({ iconProps: { iconName: 'Share' } });
break;
default:
break;
}
});
}

switch (size) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Each case returns the same DOM as far as I can tell. Intentional as an area of extensibility later?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes exactly!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, we should not add extra prototype code that we know will need to change eventually. Let's just add to this when we get there. Maybe add a @todo comment to mention what you intend to do.

case "xsmall":
return (
<ChicletCard {...chicletCardProps} className={ mergeStyles(this._classNames.root) } onClick={ this._onClick } actions={ actionsToIButtonProps } />
);
case "small":
return (
<ChicletCard {...chicletCardProps} className={ mergeStyles(this._classNames.root) } onClick={ this._onClick } actions={ actionsToIButtonProps } />
);
case "medium":
case "large":
case "xlarge":
return (
<ChicletCard {...chicletCardProps} className={ mergeStyles(this._classNames.root) } onClick={ this._onClick } actions={ actionsToIButtonProps } />
);
default:
return (
<ChicletCard {...chicletCardProps} className={ mergeStyles(this._classNames.root) } onClick={ this._onClick } actions={ actionsToIButtonProps } />
);
}
}

private _onClick(): void {
console.log("You clicked the Chiclet");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// @todo: default click handler

}
}
Loading