feat: add popover as a fragment component#304
Conversation
✅ Deploy Preview for carbon-components-builder ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Signed-off-by: Max You <JianzhongMax.You@ibm.com>
|
Verified that the component features and export works. |
| <svg _ngcontent-pla-c12="" preserveAspectRatio="xMidYMid meet" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 32 32"> | ||
| <path _ngcontent-pla-c12="" d="M26,4H6A2,2,0,0,0,4,6V26a2,2,0,0,0,2,2H26a2,2,0,0,0,2-2V6A2,2,0,0,0,26,4ZM6,26V6H26V26Z"> | ||
| </path> | ||
| </svg> |
There was a problem hiding this comment.
You're hard coding icon here.
Ideally, we would want to allow the user to specify the tooltip trigger... so not sure what the best way to approach this is. I guess we can have an icon as an option here? @zvonimirfras @maxxyouu
| keywords: ['popover'], | ||
| name: 'Popover', | ||
| type: 'popover', | ||
| defaultComponentObj: { | ||
| type: 'popover', | ||
| isOpen: true |
| v10: { | ||
| inputs: ({ json }) => ` | ||
| @Input() ${nameStringToVariableString(json.codeContext?.name)}IsOpen = ${json.isOpen}; | ||
| @Input() ${nameStringToVariableString(json.codeContext?.name)}IsShowCaret = ${json.isShowCaret}; | ||
| @Input() ${nameStringToVariableString(json.codeContext?.name)}IsDropShadow = ${json.isDropShadow}; | ||
| @Input() ${nameStringToVariableString(json.codeContext?.name)}IsHighContrast = ${json.isHighContrast}; | ||
| @Input() ${nameStringToVariableString(json.codeContext?.name)}Align: any = '${json.align ? json.align : 'bottom'}'; | ||
| @Input() ${nameStringToVariableString(json.codeContext?.name)}Text = '${json.text}'; | ||
| `, | ||
| outputs: ({ json }) => ` | ||
| @Output() ${nameStringToVariableString(json.codeContext?.name)}OnOpen = new EventEmitter(); | ||
| @Output() ${nameStringToVariableString(json.codeContext?.name)}OnClose = new EventEmitter(); | ||
| @Output() ${nameStringToVariableString(json.codeContext?.name)}IsOpenChange = new EventEmitter();`, | ||
| imports: ['PopoverModule'], | ||
| code: ({ json }) => { | ||
| return `<div | ||
| cdsPopover | ||
| ${angularClassNamesFromComponentObj(json)} | ||
| [isOpen]="${nameStringToVariableString(json.codeContext?.name)}IsOpen" | ||
| [dropShadow]="${nameStringToVariableString(json.codeContext?.name)}IsDropShadow" | ||
| [align]="${nameStringToVariableString(json.codeContext?.name)}Align" | ||
| [caret]="${nameStringToVariableString(json.codeContext?.name)}IsShowCaret" | ||
| [highContrast]="${nameStringToVariableString(json.codeContext?.name)}IsHighContrast" | ||
| (onOpen)="${nameStringToVariableString(json.codeContext?.name)}OnOpen.emit($event)" | ||
| (onClose)="${nameStringToVariableString(json.codeContext?.name)}onClose.emit($event)" | ||
| (isOpenChange)="${nameStringToVariableString(json.codeContext?.name)}IsOpenChange.emit($event)"> | ||
| <div class="popover-trigger"> | ||
| <svg preserveAspectRatio="xMidYMid meet" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 32 32"> | ||
| <path d="M26,4H6A2,2,0,0,0,4,6V26a2,2,0,0,0,2,2H26a2,2,0,0,0,2-2V6A2,2,0,0,0,26,4ZM6,26V6H26V26Z"></path> | ||
| </svg> | ||
| </div> | ||
| <cds-popover-content> | ||
| <div style="padding: 1rem"> | ||
| ${ json.text } | ||
| </div> | ||
| </cds-popover-content> | ||
| </div> | ||
| `; | ||
| } | ||
| } | ||
| }, |
There was a problem hiding this comment.
Leave v10 input and output as blank. This component did NOT exist in v10.
| v10: { | ||
| imports: ['Popover', 'PopoverContent'], | ||
| code: ({ json }) => { | ||
| return `<Popover | ||
| open={${json.isOpen ? json.isOpen : false}} | ||
| align={${json.align ? json.align : (json.isTabTip ? 'bottom-start' : 'bottom')}} | ||
| caret={${json.isShowCaret ? json.isShowCaret : (json.isTabTip ? false : true)}} | ||
| dropShadow={${json.isDropShadow ? json.isDropShadow : true}} | ||
| highContrast={${json.isHighContrast ? json.isHighContrast : true}} | ||
| ${json.isTabTip ? 'isTabTip' : ''} | ||
| ${reactClassNamesFromComponentObj(json)}> | ||
| <PopoverContent> | ||
| ${ json.text } | ||
| </PopoverContent> | ||
| </Popover>`; | ||
| } | ||
| } |
There was a problem hiding this comment.
Leave v10 input and output as blank. This component did NOT exist in v10.
| } | ||
| } | ||
| } | ||
| }; No newline at end of file |
| const alignItems = [ | ||
| {id: 'top', text: 'Top'}, | ||
| {id: 'right', text: 'Right'}, | ||
| {id: 'bottom', text: 'Bottom'}, | ||
| {id: 'left', text: 'Left'} | ||
| ]; |
There was a problem hiding this comment.
There are way more align items than this. See https://github.com/carbon-design-system/carbon/blob/b3488785126adecd6709370d2bd7786133d83213/packages/react/src/components/Popover/index.tsx#L48
| component: APopOver, | ||
| settingsUI: APopOverSettingsUI, | ||
| codeUI: APopOverCodeUI, |
There was a problem hiding this comment.
Should be APopover, fix all instances,
| component: APopOver, | |
| settingsUI: APopOverSettingsUI, | |
| codeUI: APopOverCodeUI, | |
| component: APopover, | |
| settingsUI: APopoverSettingsUI, | |
| codeUI: APopoverCodeUI, |
| codeExport: { | ||
| angular: { | ||
| latest: { | ||
| inputs: ({ json }) => ` |
There was a problem hiding this comment.
Extra indentation? Have you ran the linter?
| return `<div | ||
| cdsPopover |
Signed-off-by: Max You <JianzhongMax.You@ibm.com>
Signed-off-by: Max You <JianzhongMax.You@ibm.com>
Signed-off-by: Max You <JianzhongMax.You@ibm.com>
Signed-off-by: Max You <JianzhongMax.You@ibm.com>
Signed-off-by: Max You <JianzhongMax.You@ibm.com>
zvonimirfras
left a comment
There was a problem hiding this comment.
indentation of many files here is a bit all over the place
Let's fix that before moving forward, it's hard to read at the moment.
| open={state.isOpen ? state.isOpen : false} | ||
| align={state.align ? state.align : (state.isTabTip ? 'bottom-start' : 'bottom')} | ||
| caret={state.isShowCaret ? state.isShowCaret : (state.isTabTip ? false : true)} | ||
| dropShadow={state.isDropShadow ? state.isDropShadow : true} | ||
| highContrast={state.isHighContrast ? state.isHighContrast : true} | ||
| isTabTip={state.isTabTip ? state.isTabTip : false}> |
| import { styleObjectToString } from '@carbon-builder/player-react'; | ||
|
|
||
| export const APopoverSettingsUI = ({ selectedComponent, setComponent }: any) => { | ||
|
|
| { id: 'right-start', text: 'Right start' } | ||
| ]; | ||
|
|
||
| return <> |
There was a problem hiding this comment.
indentation of the whole return
| type: 'popover', | ||
| defaultComponentObj: { | ||
| type: 'popover', | ||
| label: 'popover', |
| defaultComponentObj: { | ||
| type: 'popover', | ||
| label: 'popover', | ||
| isOpen: true |

#305