Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"packageName": "@uifabric/experiments",
"comment": "Implementation of the Chiclet component",
"type": "minor"
}
],
"packageName": "@uifabric/experiments",
"email": "naethell@microsoft.com"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"packageName": "office-ui-fabric-react",
"comment": "Implementation of experimental chiclet component",
"type": "minor"
}
],
"packageName": "office-ui-fabric-react",
"email": "naethell@microsoft.com"
}
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="docx">
<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://static2.sharepointonline.com/files/fabric/assets/brand-icons/document/svg/docx_48x1.svg">

<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',
};
51 changes: 51 additions & 0 deletions packages/experiments/src/components/Chiclet/Chiclet.base.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import * as React from 'react';
import {
BaseComponent,
customizable
} from '../../Utilities';
import { ChicletCard } from './ChicletCard';
import { getOpenGraphProperties } from './OpenGraph';
import { IChicletProps, ChicletSize } from './Chiclet.types';
import { IChicletCardProps } from './ChicletCard.types';

export interface IChicletState {
chicletCardProps?: IChicletCardProps;
}

@customizable('ChicletBase', ['theme'])
export class ChicletBase extends BaseComponent<IChicletProps, IChicletState> {

constructor(props: IChicletProps) {
super(props);

const chicletCardProps = getOpenGraphProperties(this.props.url);
this.state = { chicletCardProps: chicletCardProps };
}

public render(): JSX.Element {
const { size, footer, description } = this.props;
const { chicletCardProps } = this.state;

switch (size) {
case ChicletSize.medium:
return (
<ChicletCard { ...chicletCardProps } onClick={ this._onClick } footer={ footer } description={ description } />
);
// @todo: handle other types of chiclets
default:
return (
<ChicletCard { ...chicletCardProps } onClick={ this._onClick } footer={ footer } description={ description } />
);
}
}

public componentWillReceiveProps(nextProps: IChicletProps): void {
if (this.props.url !== nextProps.url) {
this.setState({ chicletCardProps: getOpenGraphProperties(this.props.url) });
}
}

private _onClick(): void { // @todo: default click handler
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { IChicletStyleProps, IChicletStyles } from './Chiclet.types';

export const getStyles = (
props: IChicletStyleProps
): IChicletStyles => {
return ({
root: {}
});
};
13 changes: 13 additions & 0 deletions packages/experiments/src/components/Chiclet/Chiclet.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { styled } from '../../Utilities';
import {
IChicletProps,
IChicletStyleProps,
IChicletStyles
} from './Chiclet.types';
import { getStyles } from './Chiclet.styles';
import { ChicletBase } from './Chiclet.base';

export const Chiclet = styled<IChicletProps, IChicletStyleProps, IChicletStyles>(
ChicletBase,
getStyles
);
90 changes: 90 additions & 0 deletions packages/experiments/src/components/Chiclet/Chiclet.types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
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.

Let's split this file into 3 one for each component: ChicletCard.types.ts, Chiclet.types.ts and BaseChiclet.types.ts

import { ChicletBase } from './Chiclet.base';
import { IStyleFunction } from '../../Utilities';
import {
IStyle,
ITheme
} from '../../Styling';

export interface IChiclet {

}

export interface IChicletProps extends React.Props<ChicletBase> {
/**
* Optional callback to access the IChiclet interface. Use this instead of ref for accessing
* the public methods and properties of the component.
*/
componentRef?: (component: IChiclet | null) => void;

/**
* Call to provide customized styling that will layer on top of the variant rules.
*/
getStyles?: IStyleFunction<IChicletStyleProps, IChicletStyles>;

/**
* Optional class for chiclet.
*/
className?: string;

/**
* Sharing link
*/
url: string;

/**
* Chiclet size to render
*/
size?: ChicletSize;

/**
* Description to render for the component.
*/
description?: React.ReactElement<JSX.Element>;

/**
* Footer to render for the component.
*/
footer?: React.ReactElement<JSX.Element>;

/**
* Theme for the component.
*/
theme?: ITheme;
}

export interface IChicletStyleProps {
/**
* Theme for the component.
*/
theme?: ITheme;
}

export interface IChicletStyles {
/**
* Style for the root element when fixed.
*/
root?: IStyle;
}

export enum ChicletSize {
/**
* X-Small Chiclet
*/
xSmall = 0,

/**
* Small Chiclet
*/
small = 1,

/**
* Medium Chiclet
*/
medium = 2,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium [](start = 2, length = 6)

The naming convention for enum members is InitialCaps

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.

Most enums in the fabric codebase seem to be lowerCamelCased... let's go with consistency now, and if we want to change the convention, do it all in one go?


/**
* Large Chiclet
*/
large = 3
}
162 changes: 162 additions & 0 deletions packages/experiments/src/components/Chiclet/ChicletCard.base.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
import * as React from 'react';
import {
BaseComponent,
css,
customizable,
classNamesFunction
} from '../../Utilities';
import { IChicletCardStyles, IChicletCardStyleProps, IChicletCardProps } from './ChicletCard.types';
import { mergeStyles } from '../../Styling';
import { Image } from 'office-ui-fabric-react/lib/Image';

const getClassNames = classNamesFunction<IChicletCardStyleProps, IChicletCardStyles>();

const ASSET_CDN_BASE_URL = 'https://static2.sharepointonline.com/files/fabric/assets';

const PREVIEW_IMAGE_WIDTH = '198px';
const PREVIEW_IMAGE_HEIGHT = '122px';

@customizable('ChicletCardBase', ['theme'])
export class ChicletCardBase extends BaseComponent<IChicletCardProps, {}> {
public static defaultProps: IChicletCardProps = {
imageWidth: PREVIEW_IMAGE_WIDTH,
imageHeight: PREVIEW_IMAGE_HEIGHT
};

private _classNames: { [key in keyof IChicletCardStyles]: string };

public render(): JSX.Element {
const {
title,
itemType,
description,
image,
imageWidth,
imageHeight,
imageAlt,
url,
onClick,
className,
footer,
theme,
getStyles
} = this.props;
const actionable = (onClick) ? true : false;

this._classNames = getClassNames(getStyles, { theme: theme! });

// if this element is actionable it should have an aria role
const role = actionable ? (onClick ? 'button' : 'link') : undefined;
const tabIndex = actionable ? 0 : undefined;

const preview = this._renderPreviewImage(image, imageHeight, imageWidth, itemType, imageAlt);

return (
<div
tabIndex={ tabIndex }
role={ role }
onClick={ actionable ? this._onClick : undefined }
className={
css('ms-ChicletCard', className, mergeStyles(this._classNames.root)) }
>
<div
className={ mergeStyles(this._classNames.preview) }
>
{ preview }
</div>
<div
className={ mergeStyles(this._classNames.info) }
>
<div
className={ mergeStyles(this._classNames.title) }
>
{ title ? title : (null) }
</div>
<div
className={ mergeStyles(this._classNames.description) }
>
{ description ? description : url }
</div>
{ footer }
</div>
</div>
);
}

private _renderPreviewImage(imageUrl?: string, imageHeight?: string, imageWidth?: string, itemType?: string, imageAlt?: string)
: React.ReactElement<React.HTMLAttributes<HTMLDivElement>> {
let image;
if (imageUrl) {
image = (
<Image
width={ imageWidth }
height={ imageHeight }
src={ imageUrl }
role='presentation'
alt={ imageAlt ? imageAlt : undefined }
/>
);
} else {
image = (
<Image
width={ PREVIEW_IMAGE_WIDTH }
height={ PREVIEW_IMAGE_HEIGHT }
src={ itemType
? `${ASSET_CDN_BASE_URL}/brand-icons/document/svg/` + itemType + `_48x1.svg`
: (undefined) /* @todo: this will be replaced by something built by the design team */ }
role='presentation'
alt={ imageAlt ? imageAlt : undefined }
/>
);
}

let src;
if (itemType !== null) {
src = `${ASSET_CDN_BASE_URL}/brand-icons/product/svg/` + itemType + `_16x1_5.svg`;
}
let icon = <img className={ mergeStyles(this._classNames.icon) } src={ src } />;
switch (itemType) { // for "hero" apps, we'll use the app icons
case 'word':
case 'docx':
icon = (
<img
className={ mergeStyles(this._classNames.icon) }
src={ `${ASSET_CDN_BASE_URL}/brand-icons/product/svg/word_16x1_5.svg` }
/>
);
break;
case 'powerpoint':
case 'pptx':
icon = (
<img
className={ mergeStyles(this._classNames.icon) }
src={ `${ASSET_CDN_BASE_URL}/brand-icons/product/svg/powerpoint_16x1_5.svg` }
/>
);
break;
case 'excel':
icon = (
<img
className={ mergeStyles(this._classNames.icon) }
src={ `${ASSET_CDN_BASE_URL}/brand-icons/product/svg/excel_16x1_5.svg` }
/>
);
break;
}

return (
<div>
{ image }
{ icon }
</div>
);
}

private _onClick = (ev: React.MouseEvent<HTMLElement>): void => {
const { onClick } = this.props;
if (onClick) {
onClick(ev);
}
}

}
Loading