Shoelace: A forward-thinking library of web components

Share your advanced knowledge/code with the community.
User avatar
Peter
Posts: 1001
Joined: Mon Feb 24, 2014 10:17 pm
Location: 127.0.0.1:9080
Contact:

Shoelace: A forward-thinking library of web components

Post by Peter »

Just a little quick code for those who want to use the Shoelace library:

Code: Select all

! $("<link rel='stylesheet' href='https://cdn.jsdelivr.net/npm/@shoelace-style/shoelace@2.0.0-beta.83/dist/themes/light.css' />").appendTo("head");
! $("<script type='module' src='https://cdn.jsdelivr.net/npm/@shoelace-style/shoelace@2.0.0-beta.83/dist/shoelace.js' defer></script>").appendTo("head");

Procedure AddButton(ButtonText.s)
  
  ! $(`<sl-button id='cmdOpenDialog'>${v_buttontext}</sl-button>`).appendTo("body");
  
EndProcedure

Procedure AddDialog(DialogHeader.s, DialogBody.s)
  
  ! $(` <sl-dialog label='${v_dialogheader}' class='dialog-overview'>
  !       ${v_dialogbody}
  !       <sl-button id='cmdCloseDialog' slot='footer' variant='primary'>Close</sl-button>
  !     </sl-dialog>`).appendTo("body");
  
EndProcedure

AddDialog("Dialog", "Lorem ipsum dolor sit amet, consectetur adipiscing elit.")

AddButton("Open Dialog")

! const dialog      = document.querySelector('.dialog-overview');
! const openButton  = document.getElementById('cmdOpenDialog')
! const closeButton = document.getElementById('cmdCloseDialog')

! openButton.addEventListener('click', () => dialog.show());
! closeButton.addEventListener('click', () => dialog.hide());
Image
bembulak
Posts: 40
Joined: Wed Feb 26, 2014 9:53 am

Re: Shoelace: A forward-thinking library of web components

Post by bembulak »

That's a nice one!
Didn't know about Shoelace, but it looks good.
Post Reply