-
Notifications
You must be signed in to change notification settings - Fork 377
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'beyackle/addAriaRegions' of https://github.com/microsof…
…t/BotFramework-Composer into beyackle/addAriaRegions
- Loading branch information
Showing
4 changed files
with
39 additions
and
12 deletions.
There are no files selected for viewing
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
34 changes: 34 additions & 0 deletions
34
Composer/packages/lib/ui-shared/src/components/PropertyAssignment.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,34 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
import React, { FC } from 'react'; | ||
|
||
import { SingleLineDiv } from '../styled'; | ||
|
||
type Expression = string; | ||
type AssignmentValue = string | number | boolean | Expression | object | any[]; | ||
|
||
export interface PropertyAssignmentProps { | ||
property: string; | ||
value?: AssignmentValue; | ||
} | ||
|
||
const AssignmentOpt = ':'; | ||
const NullValuePlaceholder = '?'; | ||
|
||
const serializeAssignmentValue = (value?: AssignmentValue): string | number | boolean => { | ||
if (typeof value === 'object') { | ||
return JSON.stringify(value); | ||
} | ||
return value ?? NullValuePlaceholder; | ||
}; | ||
|
||
export const PropertyAssignment: FC<PropertyAssignmentProps> = ({ property, value }) => { | ||
const valueStr = serializeAssignmentValue(value); | ||
const content = `${property} ${AssignmentOpt} ${valueStr}`; | ||
return ( | ||
<SingleLineDiv height={16} title={content}> | ||
{content} | ||
</SingleLineDiv> | ||
); | ||
}; |
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 |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
// Licensed under the MIT License. | ||
|
||
export * from './ListOverview'; | ||
export * from './PropertyAssignment'; |
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