-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add popover as a fragment component #304
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Max You <[email protected]>
Signed-off-by: Max You <[email protected]>
Signed-off-by: Max You <[email protected]>
✅ 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 <[email protected]>
Signed-off-by: Max You <[email protected]>
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leave v10 input and output as blank. This component did NOT exist in v10.
} | ||
} | ||
} | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing new line
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra indentation? Have you ran the linter?
return `<div | ||
cdsPopover |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Identation - run linter
Signed-off-by: Max You <[email protected]>
Signed-off-by: Max You <[email protected]>
Signed-off-by: Max You <[email protected]>
Signed-off-by: Max You <[email protected]>
Signed-off-by: Max You <[email protected]>
Signed-off-by: Max You <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indentation
import { styleObjectToString } from '@carbon-builder/player-react'; | ||
|
||
export const APopoverSettingsUI = ({ selectedComponent, setComponent }: any) => { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{ id: 'right-start', text: 'Right start' } | ||
]; | ||
|
||
return <> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indentation of the whole return
type: 'popover', | ||
defaultComponentObj: { | ||
type: 'popover', | ||
label: 'popover', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs a better label
defaultComponentObj: { | ||
type: 'popover', | ||
label: 'popover', | ||
isOpen: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this default?
#305