-
Notifications
You must be signed in to change notification settings - Fork 378
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: repaint ui for setProperties in visual editor (#2017)
* elements interface * styled component * use styledComponent in visual editor * refactor * add styled package * module name * revert uischema & refactor itemOverview component * ui adjust * rename & delete needless code * truncate text * copy formcard to listoverviewcard for choiceinput and setProperties * refactor code * delete listOverviewWidget * css * fix some bug Co-authored-by: Andy Brown <asbrown002@gmail.com>
- Loading branch information
1 parent
998219a
commit aed7c65
Showing
11 changed files
with
314 additions
and
184 deletions.
There are no files selected for viewing
84 changes: 0 additions & 84 deletions
84
Composer/packages/extensions/visual-designer/__tests__/widgets/ChoiceInput.test.tsx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
Composer/packages/extensions/visual-designer/src/components/common/ListOverview.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
import React, { FC } from 'react'; | ||
|
||
import { SingleLineDiv } from '../elements/styledComponents'; | ||
|
||
export interface ListOverviewProps { | ||
items: string[]; | ||
renderItem: (item: object | string) => JSX.Element; | ||
maxCount: number; | ||
} | ||
export const ListOverview: FC<ListOverviewProps> = ({ items, renderItem, maxCount }) => { | ||
if (!Array.isArray(items)) { | ||
return null; | ||
} | ||
return ( | ||
<div style={{ padding: '0 0 8px 8px' }}> | ||
{items.slice(0, maxCount).map((item, index) => { | ||
return ( | ||
<div style={{ marginTop: '8px' }} key={index}> | ||
{renderItem(item)} | ||
</div> | ||
); | ||
})} | ||
{items.length > maxCount ? ( | ||
<SingleLineDiv | ||
data-testid="hasMore" | ||
style={{ | ||
marginTop: '8px', | ||
textAlign: 'center', | ||
}} | ||
> | ||
{`${items.length - maxCount} more`} | ||
</SingleLineDiv> | ||
) : null} | ||
</div> | ||
); | ||
}; |
64 changes: 64 additions & 0 deletions
64
Composer/packages/extensions/visual-designer/src/components/elements/styledComponents.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
import { css } from '@emotion/core'; | ||
import styled from '@emotion/styled'; | ||
import { Link } from 'office-ui-fabric-react/lib/Link'; | ||
|
||
import { ObiColors } from '../../constants/ElementColors'; | ||
|
||
import { MultiLineDivProps, DivProps } from './styledComponents.types'; | ||
|
||
const dynamicStyle = props => | ||
css` | ||
color: ${props.color || ObiColors.Black}; | ||
`; | ||
|
||
export const LinkBtn = styled(Link)(props => ({ | ||
color: props.color || ObiColors.AzureBlue, | ||
})); | ||
|
||
export const Span = styled.span` | ||
${dynamicStyle} | ||
`; | ||
|
||
export const BorderedDiv = styled.div<DivProps>(props => ({ | ||
color: props.color || ObiColors.Black, | ||
width: props.width, | ||
height: props.height, | ||
padding: '2px 0 0 8px', | ||
whiteSpace: 'nowrap', | ||
textOverflow: 'ellipsis', | ||
overflow: 'hidden', | ||
fontFamily: 'Segoe UI', | ||
fontSize: '12px', | ||
lineHeight: '14px', | ||
border: '1px solid #C4C4C4', | ||
boxSizing: 'border-box', | ||
})); | ||
|
||
export const MultiLineDiv = styled.div<MultiLineDivProps>(props => ({ | ||
color: props.color || ObiColors.Black, | ||
fontSize: '12px', | ||
height: `${(props.lineNum || 1) * 19}px`, | ||
lineHeight: '19px', | ||
fontFamily: 'Segoe UI', | ||
overflow: 'hidden', | ||
textOverflow: 'ellipsis', | ||
wordBreak: 'break-word', | ||
display: '-webkit-box', | ||
'-webkit-line-clamp': `${props.lineNum || 1}`, | ||
'-webkit-box-orient': 'vertical', | ||
})); | ||
|
||
export const SingleLineDiv = styled.div<DivProps>(props => ({ | ||
width: props.width || 150, | ||
height: props.height || '19px', | ||
color: props.color || ObiColors.Black, | ||
fontSize: '12px', | ||
whiteSpace: 'nowrap', | ||
textOverflow: 'ellipsis', | ||
overflow: 'hidden', | ||
lineHeight: '19px', | ||
fontFamily: 'Segoe UI', | ||
})); |
15 changes: 15 additions & 0 deletions
15
...ser/packages/extensions/visual-designer/src/components/elements/styledComponents.types.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
import { DetailedHTMLProps, HTMLAttributes, ComponentClass, FC } from 'react'; | ||
|
||
export type ElementProps = DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>; | ||
export interface DivProps extends ElementProps { | ||
width?: number; | ||
height?: number; | ||
} | ||
|
||
export interface MultiLineDivProps extends DivProps { | ||
lineNum?: number; | ||
} | ||
export type ElementComponent<T extends ElementProps> = FC<T> | ComponentClass<T, any>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.