Skip to content
This repository has been archived by the owner on Mar 4, 2020. It is now read-only.

chore(types): make Props param in ShorthandValue and ShorthandCollection required #1605

Merged
merged 24 commits into from
Jul 15, 2019
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
6d9a055
chore(types): make Props param in ShorthandValue and ShorthandCollect…
layershifter Jul 9, 2019
206ae59
Merge branches 'chore/type-script' and 'master' of https://github.com…
layershifter Jul 12, 2019
5011ce3
fix issues
layershifter Jul 12, 2019
8424893
fix types
layershifter Jul 12, 2019
08e9ae5
fix types
layershifter Jul 12, 2019
2c381e4
fix imports
layershifter Jul 15, 2019
07a0cf8
replace ShorthandValue[]
layershifter Jul 15, 2019
8f80f48
fix type
layershifter Jul 15, 2019
d052f49
fix usage of `ShorthandValue[]`
layershifter Jul 15, 2019
ad9794b
Merge branch 'master' of https://github.com/stardust-ui/react into ch…
layershifter Jul 15, 2019
259f0c1
fix type
layershifter Jul 15, 2019
74345ac
type `reactions` in examples
layershifter Jul 15, 2019
7cdc950
fix `message` type
layershifter Jul 15, 2019
0746ab4
update to use ShorthandCollection<ListItemProps>
layershifter Jul 15, 2019
af0fdb1
Merge branch 'master' of https://github.com/stardust-ui/react into ch…
layershifter Jul 15, 2019
ca3ed3b
fix types in DropdownItem
layershifter Jul 15, 2019
9cf742d
remove cruft content
layershifter Jul 15, 2019
64db046
add a comment
layershifter Jul 15, 2019
ca591f8
fix type
layershifter Jul 15, 2019
e01367c
fix last review comment
layershifter Jul 15, 2019
a7aa992
Merge branches 'chore/type-script' and 'master' of https://github.com…
layershifter Jul 15, 2019
8f52297
add changelog entry
layershifter Jul 15, 2019
879a602
fix types in `ChatMessage`
layershifter Jul 15, 2019
afd981e
fix CH entry
layershifter Jul 15, 2019
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
5 changes: 3 additions & 2 deletions docs/src/components/ColorSchemes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@ import {
ComponentSlotStylesInput,
ThemePrepared,
Grid,
ShorthandValue,
Header,
HeaderProps,
ShorthandCollection,
} from '@stardust-ui/react'

import ColorBox from './ColorBox'

type ColorVariantsProps = {
name?: string
themes?: ThemePrepared[]
headers?: ShorthandValue[]
headers?: ShorthandCollection<HeaderProps>
}

export const colorVariantsStyles: ComponentSlotStylesInput<ColorVariantsProps> = {
Expand Down
21 changes: 15 additions & 6 deletions docs/src/components/ComponentBestPractices.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
import * as React from 'react'
import _ from 'lodash'
import { Box, Flex, Header, Icon, List, Segment, ShorthandValue } from '@stardust-ui/react'
import * as _ from 'lodash'
import {
Box,
Flex,
Header,
Icon,
List,
ListItemProps,
Segment,
ShorthandCollection,
} from '@stardust-ui/react'
import { Extendable } from 'src/types'

export type ComponentBestPracticesProps = Extendable<{
doList?: ShorthandValue<{}>[]
dontList?: ShorthandValue<{}>[]
doList?: ShorthandCollection<ListItemProps>
dontList?: ShorthandCollection<ListItemProps>
}>

const ComponentBestPractices: React.FC<ComponentBestPracticesProps> = ({ doList, dontList }) => {
const updatedDoList: ShorthandValue<{}>[] = []
const updatedDontList: ShorthandValue<{}>[] = []
const updatedDoList: ShorthandCollection<ListItemProps> = []
const updatedDontList: ShorthandCollection<ListItemProps> = []

if (_.size(doList) > 0) {
_.map(doList, element => {
Expand Down
2 changes: 1 addition & 1 deletion docs/src/components/Sidebar/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ class Sidebar extends React.Component<any, any> {
}
}

getTreeItems(): ShorthandValue[] {
getTreeItems(): TreeProps['items'] {
return [
{
key: 'concepts',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Avatar, Chat } from '@stardust-ui/react'
import { Avatar, Chat, ChatItemProps, ShorthandCollection } from '@stardust-ui/react'
import * as React from 'react'

const actionMenu = {
Expand All @@ -9,7 +9,7 @@ const actionMenu = {
],
}

const items = [
const items: ShorthandCollection<ChatItemProps> = [
{
attached: 'top',
contentPosition: 'end',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Avatar, Chat } from '@stardust-ui/react'
import { Avatar, Chat, ChatItemProps, ReactionProps, ShorthandCollection } from '@stardust-ui/react'
import * as React from 'react'

const reactions = [
const reactions: ShorthandCollection<ReactionProps> = [
{ key: 'up', icon: 'thumbs up', content: '1K' },
{ key: 'down', icon: 'thumbs down', content: 5 },
]

const items = [
const items: ShorthandCollection<ChatItemProps> = [
{
attached: 'top',
contentPosition: 'end',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import * as React from 'react'
import { Avatar, Chat } from '@stardust-ui/react'
import { Avatar, Chat, ChatItemProps, ReactionProps, ShorthandCollection } from '@stardust-ui/react'

const reactions = [
const reactions: ShorthandCollection<ReactionProps> = [
{ icon: 'thumbs up', content: '1K', key: 'likes', variables: { meReacting: true }, as: 'button' },
{ icon: 'thumbs down', content: 2, key: 'dislikes', as: 'button' },
]

const items = [
const items: ShorthandCollection<ChatItemProps> = [
{
attached: 'top',
contentPosition: 'end',
Expand Down
4 changes: 2 additions & 2 deletions docs/src/examples/components/Chat/Rtl/ChatExample.rtl.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react'
import { Avatar, Chat } from '@stardust-ui/react'
import { Avatar, Chat, ChatItemProps, ShorthandCollection } from '@stardust-ui/react'

const items = [
const items: ShorthandCollection<ChatItemProps> = [
{
message: (
<Chat.Message
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import * as React from 'react'
import { Avatar, Chat, Divider } from '@stardust-ui/react'
import { Avatar, Chat, ChatItemProps, Divider, ShorthandCollection } from '@stardust-ui/react'

const janeAvatar = {
image: 'public/images/avatar/small/ade.jpg',
status: { color: 'green', icon: 'check' },
}

const items = [
const items: ShorthandCollection<ChatItemProps> = [
{
message: (
<Chat.Message content="Hello" author="John Doe" timestamp="Yesterday, 10:15 PM" mine />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react'
import { Avatar, Chat } from '@stardust-ui/react'
import { Avatar, Chat, ChatItemProps, ShorthandCollection } from '@stardust-ui/react'

const [janeAvatar, johnAvatar] = [
'public/images/avatar/small/ade.jpg',
Expand All @@ -9,7 +9,7 @@ const [janeAvatar, johnAvatar] = [
status: { color: 'green', icon: 'check' },
}))

const items = [
const items: ShorthandCollection<ChatItemProps> = [
{
contentPosition: 'start',
gutter: <Avatar {...johnAvatar} />,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import * as React from 'react'
import { Avatar, Chat } from '@stardust-ui/react'
import { Avatar, Chat, ChatItemProps, ShorthandCollection } from '@stardust-ui/react'

const janeAvatar = {
image: 'public/images/avatar/small/ade.jpg',
status: { color: 'green', icon: 'check' },
}

const items = [
const items: ShorthandCollection<ChatItemProps> = [
{
message: (
<Chat.Message
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
import * as React from 'react'
import { Avatar, Chat, Provider } from '@stardust-ui/react'
import {
Avatar,
AvatarProps,
Chat,
Provider,
ReactionProps,
ShorthandCollection,
} from '@stardust-ui/react'

const reactions = [
const reactions: ShorthandCollection<ReactionProps> = [
{ key: 'up', icon: 'thumbs up', content: '1K' },
{ key: 'down', icon: 'thumbs down', content: 5 },
]

const janeAvatar = {
const janeAvatar: AvatarProps = {
image: 'public/images/avatar/small/ade.jpg',
status: { color: 'green', icon: 'check' },
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react'
import { Menu, menuAsToolbarBehavior } from '@stardust-ui/react'
import { Menu, menuAsToolbarBehavior, MenuItemProps, ShorthandCollection } from '@stardust-ui/react'

const items = [
const items: ShorthandCollection<MenuItemProps> = [
{
key: 'format',
icon: {
Expand Down Expand Up @@ -115,18 +115,14 @@ const items = [
},
]

class MenuExampleToolbarShorthand extends React.Component {
render() {
return (
<Menu
defaultActiveIndex={0}
items={items}
iconOnly
accessibility={menuAsToolbarBehavior}
aria-label="Compose Editor"
/>
)
}
}
const MenuExampleToolbarShorthand = () => (
<Menu
defaultActiveIndex={0}
items={items}
iconOnly
accessibility={menuAsToolbarBehavior}
aria-label="Compose Editor"
/>
)

export default MenuExampleToolbarShorthand
2 changes: 1 addition & 1 deletion docs/src/prototypes/MenuButton/MenuButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class MenuButton extends React.Component<MenuButtonProps, MenuButtonState> {
}

handleMenuItemOverrides = (menuItemAccessibilityAttributes: AccessibilityAttributes) =>
_.map(_.get(this.props.menu, 'items'), (item: ShorthandValue) =>
_.map(_.get(this.props.menu, 'items'), (item: ShorthandValue<MenuItemProps>) =>
typeof item === 'object'
? {
...item,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
import { Chat, Provider, Avatar, ChatMessageProps } from '@stardust-ui/react'
import {
Chat,
Provider,
Avatar,
ChatMessageProps,
ShorthandCollection,
ReactionProps,
} from '@stardust-ui/react'
import * as React from 'react'
import Popover from './Popover'
import ReactionPopup from './ReactionPopup'
import { Ref } from '@stardust-ui/react-component-ref'

const reactions = [
const reactions: ShorthandCollection<ReactionProps> = [
{
icon: 'thumbs up',
content: '1K',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import * as React from 'react'
import { Avatar, Chat } from '@stardust-ui/react'
import { Avatar, Chat, ChatItemProps, ShorthandCollection } from '@stardust-ui/react'

const janeAvatar = {
image: 'public/images/avatar/small/ade.jpg',
status: { color: 'green', icon: 'check' },
}

const items = [
const items: ShorthandCollection<ChatItemProps> = [
{
message: (
<Chat.Message
Expand Down
8 changes: 5 additions & 3 deletions docs/src/prototypes/chatPane/composeMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import {
Provider,
menuAsToolbarBehavior,
MenuItemProps,
ShorthandCollection,
IconXSpacing,
} from '@stardust-ui/react'

import { Props } from 'src/types'
Expand Down Expand Up @@ -72,8 +74,8 @@ const getInputWrapperStyles = ({ attached }: ComposeMessageProps): React.CSSProp
}
}

const getMenuItems = (): MenuItemProps[] => {
const items: MenuItemProps[] = [
const getMenuItems = (): ShorthandCollection<MenuItemProps> => {
const items: ShorthandCollection<MenuItemProps> = [
'compose',
'attach',
'smile',
Expand All @@ -86,7 +88,7 @@ const getMenuItems = (): MenuItemProps[] => {
key: `${index}-${name}`,
icon: {
name,
xSpacing: 'both',
xSpacing: 'both' as IconXSpacing,
variables: siteVars => ({ color: siteVars.colors.grey[500] }),
},
'aria-label': `${name} tool`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ function generateChatMsgProps(message: MessageData, fromUser: UserData): ChatIte
}
}

function createMessageContent(message: MessageData): ShorthandValue {
function createMessageContent(message: MessageData): ShorthandValue<ChatMessageProps> {
const messageId = `content-${message.id}`
return {
id: message.withAttachment ? undefined : messageId,
Expand Down
Loading