-
Notifications
You must be signed in to change notification settings - Fork 231
Feat/top app bar/iss 499 #688
Changes from 27 commits
f8834a3
9d4ceb7
c33c2dd
6593e91
8cf11cc
f9238ef
9841e18
a376474
d141be1
dbaaf70
6a06518
802066a
9b66812
9ef9ab9
7563dff
457afee
02da75c
291cb67
0505902
a79dc3a
928d249
db46248
e78306e
a74c1bf
dc798f8
38c0417
117d091
132cb84
100c132
2f6db89
1ba5108
54cb68b
116aa67
49dd822
688c5af
19846dd
409ccea
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// The MIT License | ||
// | ||
// Copyright (c) 2019 Google, Inc. | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in | ||
// all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
|
||
import * as React from 'react'; | ||
import * as classnames from 'classnames'; | ||
import {cssClasses} from './constants'; | ||
// @ts-ignore no mdc .d.ts file | ||
|
||
|
||
interface IconProps<T> extends React.HTMLProps<T> { | ||
mgr34 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
actionItem?: boolean; | ||
className?: string; | ||
children: React.ReactElement<any>; | ||
navIcon?: boolean; | ||
} | ||
|
||
|
||
const Icon: <T extends {} = HTMLElement>(props: IconProps<T> ) => | ||
mgr34 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
React.ReactElement<HTMLElement> = ({ | ||
/* eslint-disable react/prop-types */ | ||
actionItem = false, | ||
navIcon = false, | ||
className, | ||
children, | ||
...otherProps | ||
/* eslint-enable react/prop-types */ | ||
}) => | ||
React.cloneElement(children, { | ||
...otherProps, | ||
className: classnames(className, children.props.className, { | ||
[cssClasses.ACTION_ITEM]: actionItem, | ||
[cssClasses.NAV_ICON]: navIcon, | ||
}), | ||
}); | ||
|
||
export default Icon; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// The MIT License | ||
// | ||
// Copyright (c) 2019 Google, Inc. | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in | ||
// all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
|
||
import * as React from 'react'; | ||
import * as classnames from 'classnames'; | ||
import {cssClasses} from './constants'; | ||
|
||
export interface RowProps<T> extends React.HTMLProps<T> { | ||
className?: string; | ||
tag?: string; | ||
}; | ||
|
||
const Row: <T extends {} = HTMLDivElement>(props: RowProps<T>) => | ||
mgr34 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
React.ReactElement<T> = ({ | ||
/* eslint-disable react/prop-types */ | ||
children, | ||
className, | ||
tag: Tag = 'div', | ||
...otherProps | ||
/* eslint-enable react/prop-types */ | ||
}) => ( | ||
// @ts-ignore https://github.com/Microsoft/TypeScript/issues/28892 | ||
<Tag className={classnames(className, cssClasses.ROW)} {...otherProps}> | ||
{children} | ||
</Tag> | ||
); | ||
|
||
export default Row; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// The MIT License | ||
// | ||
// Copyright (c) 2019 Google, Inc. | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in | ||
// all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
|
||
import * as React from 'react'; | ||
import * as classnames from 'classnames'; | ||
import {cssClasses} from './constants'; | ||
|
||
export interface SectionProps<T> extends React.HTMLProps<T> { | ||
align?: 'start' | 'end'; | ||
className?: string; | ||
tag?: string; | ||
}; | ||
|
||
const Section: <T extends {} = HTMLElement>(props: SectionProps<T>) => | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. extend HTMLElement here too There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is it not already extending HTMLElement? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I mean There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah gotcha. I think this should also be changed in the Dialog component I worked on last month. Should I open an issue? I probably won't get to implementing anything this week. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah! Ya an issue would be great. |
||
React.ReactElement<T> = ({ | ||
/* eslint-disable react/prop-types */ | ||
align, | ||
mgr34 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
className, | ||
children, | ||
tag: Tag = 'section', | ||
...otherProps | ||
/* eslint-enable react/prop-types */ | ||
}) => ( | ||
// @ts-ignore https://github.com/Microsoft/TypeScript/issues/28892 | ||
<Tag | ||
className={classnames(className, cssClasses.SECTION, { | ||
[cssClasses.SECTION_START]: align === 'start', | ||
[cssClasses.SECTION_END]: align === 'end', | ||
})} | ||
{...otherProps} | ||
> | ||
{children} | ||
</Tag> | ||
); | ||
|
||
export default Section; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// The MIT License | ||
// | ||
// Copyright (c) 2019 Google, Inc. | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in | ||
// all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
|
||
import * as React from 'react'; | ||
import * as classnames from 'classnames'; | ||
import {cssClasses} from './constants'; | ||
|
||
export interface TitleProps<T> extends React.HTMLProps<T> { | ||
className?: string; | ||
tag?: string; | ||
}; | ||
|
||
const Title: <T extends {} = HTMLSpanElement>(props: TitleProps<T>) => | ||
mgr34 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
React.ReactElement<T> = ({ | ||
/* eslint-disable react/prop-types */ | ||
children, | ||
className, | ||
tag: Tag = 'span', | ||
...otherProps | ||
/* eslint-enable react/prop-types */ | ||
}) => ( | ||
// @ts-ignore https://github.com/Microsoft/TypeScript/issues/28892 | ||
<Tag className={classnames(className, cssClasses.TITLE)} {...otherProps} > | ||
{children} | ||
</Tag> | ||
); | ||
|
||
export default Title; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// The MIT License | ||
// | ||
// Copyright (c) 2019 Google, Inc. | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in | ||
// all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
const BASE = 'mdc-top-app-bar'; | ||
const SECTION = `${BASE}__section`; | ||
const cssClasses = { | ||
BASE, | ||
ROW: `${BASE}__row`, | ||
SECTION, | ||
SECTION_START: `${SECTION}--align-start`, | ||
SECTION_END: `${SECTION}--align-end`, | ||
FIXED: `${BASE}--fixed`, | ||
SHORT: `${BASE}--short`, | ||
SHORT_COLLAPSED: `${BASE}--short-collapsed`, | ||
PROMINENT: `${BASE}--prominent`, | ||
DENSE: `${BASE}--dense`, | ||
TITLE: `${BASE}__title`, | ||
ACTION_ITEM: `${BASE}__action-item`, | ||
NAV_ICON: `${BASE}__navigation-icon`, | ||
}; | ||
|
||
export {cssClasses}; |
Uh oh!
There was an error while loading. Please reload this page.