Skip to content
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

Integrate web component to webkit #116

Open
wants to merge 28 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
5a74f99
webcomponents added as submodule
saadnoor Dec 2, 2021
97e94d5
add - successful test implementation of avatar icons.
saadnoor Dec 6, 2021
819fe75
Fix - get library via npm cdn
saadnoor Dec 10, 2021
fc62869
Removed submodule
saadnoor Dec 10, 2021
2b9e0a3
Fix - submodule trace removal
saadnoor Dec 10, 2021
d793389
Add - avatar icon full implementation
saadnoor Dec 10, 2021
828833e
Update - CDN Url for always getting the latest version webcomponent f…
saadnoor Dec 10, 2021
259f142
fix - code review feedback
saadnoor Dec 27, 2021
d260e98
Merge remote-tracking branch 'origin/master' into Integrate-web-compo…
saadnoor Dec 27, 2021
285a135
fix - code cleanup based of review
saadnoor Dec 27, 2021
d095629
Add - native event capture support
saadnoor Jan 10, 2022
41dbc61
Add - showcase for avatar Icons
saadnoor Jan 16, 2022
ee7f5c1
Refactor - Code cleanup on showcase
saadnoor Jan 16, 2022
2da8fe6
Refactor - Improved code of webcomponents (avatar icon)
saadnoor Jan 16, 2022
f7093fa
Fix - Updated icons
saadnoor Jan 16, 2022
d7ca88c
Merge remote-tracking branch 'origin/master' into Integrate-web-compo…
saadnoor Jan 19, 2022
48ca83e
Fix - Added the dialog showcase again
saadnoor Jan 19, 2022
dd08c04
merge conflict resolved
saadnoor Mar 17, 2022
0fe6673
Fix - Updated Id for avatar inital
saadnoor Mar 17, 2022
b536857
Fix - upper case issue with windows OS
saadnoor Mar 17, 2022
564b64e
Fix - syntax error related method end and removed code duplication
saadnoor Mar 19, 2022
a109909
Fix - introduced redraw method for avatar initial based on review
saadnoor Mar 21, 2022
cb68faf
Fix - code cleanup for redraw design in avatar initial
saadnoor Mar 21, 2022
8406c8e
Fix - removed code duplicacy
saadnoor Mar 21, 2022
0ca6ae4
Fix - avatar initial spelling mistake
saadnoor Mar 21, 2022
d1e22f0
Refactor - Updated circular avatar and removed dynamic loader
saadnoor Mar 22, 2022
a56af55
Fix - Updated avatar initial with latest webcomponent changes
saadnoor Mar 27, 2022
82db059
Merge remote-tracking branch 'origin/master' into Integrate-web-compo…
saadnoor Apr 6, 2022
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
11 changes: 10 additions & 1 deletion demo/Showcase/Showcase.bbj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ use ::WebKit/framework/PortalFrame/PortalFrame.bbj::PortalFrame
use ::WebKit/util/ClientUtil.bbj::ClientUtil
use ::WebKit/model/Menu.bbj::Menu
use ::WebKit/model/Menu.bbj::MenuItem
use ::WebKit/widgets/WebComponents/WebComponents.bbj::WebComponents
use ::WebKit/widgets/WebComponents/AvatarIcon/AvatarIcon.bbj::AvatarIcon
use ::WebKit/demo/Showcase/components/ShowCaseFrame.bbj::ShowCaseFrame
use ::WebKit/framework/LoginDialog/SampleAuthProvider.bbj::SampleAuthProvider
use ::WebKit/framework/Favorites/SampleFavoritesProvider.bbj::SampleFavoritesProvider
Expand All @@ -24,7 +26,6 @@ ClientUtil.addLocalCSS("WebKit/css/webkit.css")

bbjutils! = new ::BBUtils.bbj::BBUtils()

REM iconPool$ = STBL("icon-pool", "fa")
iconPool$ = STBL("icon-pool", "tabler")

authProvider! = new SampleAuthProvider()
Expand Down Expand Up @@ -63,6 +64,14 @@ showCaseItem!.setStartType(2)
showCaseItem! = menu!.addMenuItem(showCase!,201,"Direct - Sales - Options","Direct - Sales - Options","table")
showCaseItem!.setStartType(2)

menuItem! = menu!.addMenuItem(menu!.getRoot(),108,"Avatar Initial","Avatar Initial Demo","typography")
menuItem!.setProgram("::WebKit/demo/Showcase/ShowcasePanels/AvatarInitial.bbj::AvatarInitial")
menuItem!.setStartType(0)

menuItem! = menu!.addMenuItem(menu!.getRoot(),100,"Dialog","Dialog Panel Demo","message-circle")
menuItem!.setProgram("::WebKit/demo/Showcase/ShowcasePanels/DialogShowcase.bbj::DialogShowcase")
menuItem!.setStartType(0)

showCaseSubItem! = menu!.addMenuItem(showCaseItem!,202,"Personal - Sale","Personal - Sale","table")
showCaseSubItem!.setStartType(2)

Expand Down
68 changes: 68 additions & 0 deletions demo/Showcase/ShowcasePanels/AvatarInitial.bbj
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
use ::WebKit/demo/Showcase/ShowcaseWidget/ShowcaseWidget.bbj::ShowcaseWidget
use ::WebKit/widgets/InputField/InputField.bbj::InputField
use ::WebKit/framework/DialogPanel/DialogPanel.bbj::DialogPanel
use ::WebKit/util/ClientUtil.bbj::ClientUtil
use ::WebKit/widgets/WebComponents/WebComponents.bbj::WebComponents
use ::WebKit/widgets/WebComponents/AvatarIcon/AvatarIcon.bbj::AvatarIcon

class public AvatarInitial extends ShowcaseWidget

field private BBjChildWindow window!
field private BBjHtmlView avatarWnd!
field private InputField avatarSize!
field private InputField AvatarName!
field private BBjCheckBox CbModal!
field private BBjCheckBox CbCloseIcon!
field private BBjCheckBox CbCloseOutside!
field private BBjChildWindow panel!

method public AvatarInitial(BBjWindow wnd!)
#super!(wnd!)

#setTitle("Avatar Initial Demo")
#setIntro("This demo shows the Avatar initial")
methodend
method public void redraw(Boolean init!)
#super!.redraw(init!)

if init! then

#panel! = #getContentWindow()
#panel!.setStyle("display","flex")
#panel!.setStyle("flex-direction","column")
#panel!.setStyle("row-gap","10px")

#AvatarName! = new InputField(#panel!)
#AvatarName!.setLabel("Avatar Name")
#AvatarName!.setInput("Stephan Wald")

#avatarSize! = new InputField(#panel!)
#avatarSize!.setLabel("Size")
#avatarSize!.setInput("50")

BtnShow! = #panel!.addButton(#panel!.getAvailableControlID(),0,0,0,0,"Create Avatar")
BtnShow!.setStyle("display","flex")
BtnShow!.setStyle("justify-content","flex-end")
BtnShow!.setAttribute("theme","primary")
BtnShow!.setAttribute("expanse","l")
BtnShow!.setCallback(BBjAPI().ON_BUTTON_PUSH,#this!,"onShowDialog")

endif
methodend

method public void onShowDialog(BBjButtonPushEvent ev!)

if #avatarWnd! <> null() then
#avatarWnd!.destroy()
endif

webComponents! = new AvatarIcon(#panel!)
#avatarWnd! = CAST(BBjHtmlView, webComponents!.getView())
webComponents!.setName(#AvatarName!.getInput())
webComponents!.setSize(#avatarSize!.getInput())

#avatarWnd!.setStyle("margin","auto")

methodend

classend
4 changes: 2 additions & 2 deletions widgets/Drawer/components/DrawerFooter/DrawerFooter.bbj
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ class public DrawerFooter extends BBjWidget
declare CircularAvatar avatar!
declare BBjChildWindow wrapper!
declare BBjStaticText icon!

if init! then
avatar! = new CircularAvatar(#window!, #drawerDataModel!.getAvatarSize(),#drawerDataModel!.getAvatarUrl())
avatar! = new CircularAvatar(#window!, #drawerDataModel!.getAvatarSize(),#drawerDataModel!.getAvatarUrl(), #title!)

wrapper! = #window!.addChildWindow(#window!.getAvailableControlID(),0,0,0,0,"",$00108800$,BBjAPI().getSysGui().getAvailableContext())
wrapper!.addPanelStyle("drawerFooterWrapperWindowClosed")
wrapper!.addPanelStyle("drawerFooterWrapperWindowSmall")
Expand Down
56 changes: 56 additions & 0 deletions widgets/WebComponents/AvatarIcon/AvatarIcon.bbj
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
use ::WebKit/widgets/WebComponents/WebComponents.bbj::WebComponents
use ::WebKit/util/ClientUtil.bbj::ClientUtil

class public AvatarIcon extends WebComponents

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This class should follow the BBjWidget pattern and not use some custom methods to use the widget (drawAvatarIcon)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This class is missing some setters to update the avatar values - See BBjWidget pattern

field private static BBjTopLevelWindow Wnd!
field private static BBjWindow wnd!
field public static BBjNumber ON_AVATAR_INITIAL_CLICK = 1234
field public static BBjHtmlView htmlView!
field public static BBjString size$
field public static BBjString name$

method public AvatarIcon()

methodend

method public AvatarIcon(BBjWindow canvas!)
#wnd! = canvas!
#redraw(1)
methodend

method private BBjHtmlView configureAvatarView(BBjHtmlView htmlView!)
htmlView!.setCallback(BBjAPI.ON_NATIVE_JAVASCRIPT, #this!,"onClickAvatarInitial")
htmlView!.setStyle("border","none")
htmlView!.executeScript(#script$)
methodret htmlView!
methodend

method public void onClickAvatarInitial(BBjNativeJavaScriptEvent ev!)
#fireEvent(#ON_AVATAR_INITIAL_CLICK, ev!)
methodend

method public void redraw(Boolean init!)
if init! > 0 then
#htmlView! = #wnd!.addHtmlView(#wnd!.getAvailableControlID(),0,0,300,300,"")
#htmlView!.setText("<avatar-initial size="""+#size$+""" name="""+name$+"""></avatar-initial>")
#htmlView! = #configureAvatarView(#htmlView!)
else
#htmlView!.setText("<avatar-initial size="""+#size$+""" name="""+#name$+"""></avatar-initial>")
fi
methodend

method public void setSize(BBjString size$)
#size$ = size$
#redraw(0)
methodend

method public void setName(BBjString name$)
#name$ = name$
#redraw(0)
methodend

method public BBjHtmlView getView()
methodret #htmlView!
methodend

classend
23 changes: 23 additions & 0 deletions widgets/WebComponents/WebComponents.bbj
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
use ::BBjWidget/BBjWidget.bbj::BBjWidget

class public WebComponents extends BBjWidget

field public BBjString script$

method public WebComponents()

webComponentLibaryURL$ = STBL("web-component-library-url", err=*next)
if webComponentLibaryURL$ = "" THEN
webComponentLibaryURL$ = "https://cdn.jsdelivr.net/npm/webkit-web-components@latest/dist/web-component/web-component.esm.js"
endif

#script$ = "var script = document.createElement(""script"");"

#script$ = #script$ + "script.setAttribute(""src"",""" + webComponentLibaryURL$ + """);"

#script$ = #script$ + "script.setAttribute(""type"",""module"");"

#script$ = #script$ + "document.head.appendChild(script)"
methodend

classend
29 changes: 25 additions & 4 deletions widgets/common/CircularAvatar/CircularAvatar.bbj
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
use ::BBjWidget/BBjWidget.bbj::BBjWidget
use ::WebKit/util/DynamicLoader.bbj::DynamicLoader

use ::WebKit/util/ClientUtil.bbj::ClientUtil
use ::WebKit/widgets/WebComponents/WebComponents.bbj::WebComponents
use ::WebKit/widgets/WebComponents/AvatarIcon/AvatarIcon.bbj::AvatarIcon
class public CircularAvatar extends BBjWidget

field private BBjChildWindow window!

field private BBjString imagePath!

method public CircularAvatar(BBjWindow parent!, BBjString radius!, BBjString imagePath!)
DynamicLoader.addLocalCSS("WebKit/widgets/common/CircularAvatar/CircularAvatar.css")
ClientUtil.addLocalCSS("WebKit/widgets/common/CircularAvatar/CircularAvatar.css")

#window! = parent!.addChildWindow(parent!.getAvailableControlID(),0,0,0,0,"",$00108800$,BBjAPI().getSysGui().getAvailableContext())
#window!.addPanelStyle("circularAvatarPanelStyle")
Expand All @@ -18,6 +18,27 @@ class public CircularAvatar extends BBjWidget
#setCanvas(#window!)
#redraw(1)
methodend

method public CircularAvatar(BBjWindow parent!, BBjString radius!, BBjString imagePath!, BBjString title!)
ClientUtil.addLocalCSS("WebKit/widgets/common/CircularAvatar/CircularAvatar.css")

#window! = parent!.addChildWindow(parent!.getAvailableControlID(),0,0,0,0,"",$00108800$,BBjAPI().getSysGui().getAvailableContext())

if imagePath! = "" THEN
webComponents! = new AvatarIcon(#window!)
webComponents!.setName(title!)
webComponents!.setSize(radius!)
else
#window!.addPanelStyle("circularAvatarPanelStyle")
#window!.setPanelStyle("width", radius!)
#window!.setPanelStyle("height", radius!)
#imagePath! = imagePath!
#setCanvas(#window!)
#redraw(1)
fi

methodend



method public void redraw(Boolean init!)
Expand Down