@@ -595,7 +595,9 @@ class ManipulationSystem {
595
595
596
596
// create the contents for the editMode button
597
597
let locale = this . options . locales [ this . options . locale ] ;
598
- let button = this . _createButton ( 'editMode' , 'vis-button vis-edit vis-edit-mode' , locale [ 'edit' ] || this . options . locales [ 'en' ] [ 'edit' ] ) ;
598
+ let label = locale [ 'edit' ] || this . options . locales [ 'en' ] [ 'edit' ] ;
599
+ let icon = '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="square" stroke-linejoin="arcs"><path d="M10.114 17.464H6.637v-3.477l8.692-8.692 3.477 3.477z" stroke-width="1.5"/><circle cx="12" cy="12" r="10"/></svg>' ;
600
+ let button = this . _createButton ( 'editMode' , 'vis-button vis-edit vis-edit-mode' , icon , label ) ;
599
601
this . editModeDiv . appendChild ( button ) ;
600
602
601
603
// bind a hammer listener to the button, calling the function toggleEditMode.
@@ -693,7 +695,9 @@ class ManipulationSystem {
693
695
* @private
694
696
*/
695
697
_createAddNodeButton ( locale ) {
696
- let button = this . _createButton ( 'addNode' , 'vis-button vis-add' , locale [ 'addNode' ] || this . options . locales [ 'en' ] [ 'addNode' ] ) ;
698
+ let label = locale [ 'addNode' ] || this . options . locales [ 'en' ] [ 'addNode' ] ;
699
+ let icon = '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="square" stroke-linejoin="arcs"><circle cx="12" cy="12" r="10"></circle><line x1="12" y1="8" x2="12" y2="16"></line><line x1="8" y1="12" x2="16" y2="12"></line></svg>' ;
700
+ let button = this . _createButton ( 'addNode' , 'vis-button vis-add' , icon , label ) ;
697
701
this . manipulationDiv . appendChild ( button ) ;
698
702
this . _bindHammerToDiv ( button , this . addNodeMode . bind ( this ) ) ;
699
703
}
@@ -704,7 +708,9 @@ class ManipulationSystem {
704
708
* @private
705
709
*/
706
710
_createAddEdgeButton ( locale ) {
707
- let button = this . _createButton ( 'addEdge' , 'vis-button vis-connect' , locale [ 'addEdge' ] || this . options . locales [ 'en' ] [ 'addEdge' ] ) ;
711
+ let label = locale [ 'addEdge' ] || this . options . locales [ 'en' ] [ 'addEdge' ] ;
712
+ let icon = '<svg xmlns="http://www.w3.org/2000/svg" stroke-linejoin="arcs" stroke-linecap="square" stroke-width="2" stroke="currentColor" fill="none" height="24" width="24"><g transform="matrix(.700038 0 0 .702684 3.024926 3.026417)" stroke-width="2.852"><circle cx="16.181" cy="5.496" r="3"/><circle cx="6.744" cy="16.217" r="3"/><path d="M13.723 8.29L9.12 13.67"/></g><circle cx="12.237" cy="11.68" r="10"/><g stroke-width="2"><path d="M15.896 13.344v3.907"/><path d="M13.942 15.298h3.907"/></g></svg>' ;
713
+ let button = this . _createButton ( 'addEdge' , 'vis-button vis-connect' , icon , label ) ;
708
714
this . manipulationDiv . appendChild ( button ) ;
709
715
this . _bindHammerToDiv ( button , this . addEdgeMode . bind ( this ) ) ;
710
716
}
@@ -715,7 +721,9 @@ class ManipulationSystem {
715
721
* @private
716
722
*/
717
723
_createEditNodeButton ( locale ) {
718
- let button = this . _createButton ( 'editNode' , 'vis-button vis-edit' , locale [ 'editNode' ] || this . options . locales [ 'en' ] [ 'editNode' ] ) ;
724
+ let label = locale [ 'editNode' ] || this . options . locales [ 'en' ] [ 'editNode' ] ;
725
+ let icon = '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="square" stroke-linejoin="arcs"><path d="M10.114 17.464H6.637v-3.477l8.692-8.692 3.477 3.477z" stroke-width="1.5"/><circle cx="12" cy="12" r="10"/></svg>' ;
726
+ let button = this . _createButton ( 'editNode' , 'vis-button vis-edit' , icon , label ) ;
719
727
this . manipulationDiv . appendChild ( button ) ;
720
728
this . _bindHammerToDiv ( button , this . editNode . bind ( this ) ) ;
721
729
}
@@ -726,7 +734,9 @@ class ManipulationSystem {
726
734
* @private
727
735
*/
728
736
_createEditEdgeButton ( locale ) {
729
- let button = this . _createButton ( 'editEdge' , 'vis-button vis-edit' , locale [ 'editEdge' ] || this . options . locales [ 'en' ] [ 'editEdge' ] ) ;
737
+ let label = locale [ 'editEdge' ] || this . options . locales [ 'en' ] [ 'editEdge' ] ;
738
+ let icon = '<svg xmlns="http://www.w3.org/2000/svg" stroke-linejoin="arcs" stroke-linecap="square" stroke-width="2" stroke="currentColor" fill="none" height="24" width="24"><g transform="matrix(.700038 0 0 .702684 3.024926 3.026417)" stroke-width="2.852"><circle cx="16.181" cy="5.496" r="3"/><circle cx="6.744" cy="16.217" r="3"/><path d="M13.723 8.29L9.12 13.67"/></g><circle cx="12.237" cy="11.68" r="10"/><g stroke-width="2"><path d="M15.896 13.344v3.907"/><path d="M13.942 15.298h3.907"/></g></svg>' ;
739
+ let button = this . _createButton ( 'editEdge' , 'vis-button vis-edit' , icon , label ) ;
730
740
this . manipulationDiv . appendChild ( button ) ;
731
741
this . _bindHammerToDiv ( button , this . editEdgeMode . bind ( this ) ) ;
732
742
}
@@ -743,7 +753,9 @@ class ManipulationSystem {
743
753
} else {
744
754
deleteBtnClass = 'vis-button vis-delete' ;
745
755
}
746
- let button = this . _createButton ( 'delete' , deleteBtnClass , locale [ 'del' ] || this . options . locales [ 'en' ] [ 'del' ] ) ;
756
+ let label = locale [ 'del' ] || this . options . locales [ 'en' ] [ 'del' ] ;
757
+ let icon = '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="square" stroke-linejoin="arcs"><circle cx="12" cy="12" r="10"></circle><line x1="15" y1="9" x2="9" y2="15"></line><line x1="9" y1="9" x2="15" y2="15"></line></svg>' ;
758
+ let button = this . _createButton ( 'delete' , deleteBtnClass , icon , label ) ;
747
759
this . manipulationDiv . appendChild ( button ) ;
748
760
this . _bindHammerToDiv ( button , this . deleteSelected . bind ( this ) ) ;
749
761
}
@@ -754,7 +766,9 @@ class ManipulationSystem {
754
766
* @private
755
767
*/
756
768
_createBackButton ( locale ) {
757
- let button = this . _createButton ( 'back' , 'vis-button vis-back' , locale [ 'back' ] || this . options . locales [ 'en' ] [ 'back' ] ) ;
769
+ let icon = '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="square" stroke-linejoin="arcs"><circle cx="12" cy="12" r="10"/><path d="M12 8l-4 4 4 4M16 12H9"/></svg>' ;
770
+ let label = locale [ 'back' ] || this . options . locales [ 'en' ] [ 'back' ] ;
771
+ let button = this . _createButton ( 'back' , 'vis-button vis-back' , icon , label ) ;
758
772
this . manipulationDiv . appendChild ( button ) ;
759
773
this . _bindHammerToDiv ( button , this . showManipulatorToolbar . bind ( this ) ) ;
760
774
}
@@ -768,14 +782,19 @@ class ManipulationSystem {
768
782
* @returns {HTMLElement }
769
783
* @private
770
784
*/
771
- _createButton ( id , className , label , labelClassName = 'vis-label' ) {
785
+ _createButton ( id , className , svgIcon , label , labelClassName = 'vis-label' ) {
772
786
773
787
this . manipulationDOM [ id + 'Div' ] = document . createElement ( 'div' ) ;
774
788
this . manipulationDOM [ id + 'Div' ] . className = className ;
775
789
this . manipulationDOM [ id + 'Label' ] = document . createElement ( 'div' ) ;
776
790
this . manipulationDOM [ id + 'Label' ] . className = labelClassName ;
777
791
this . manipulationDOM [ id + 'Label' ] . innerHTML = label ;
792
+ this . manipulationDOM [ id + 'Icon' ] = document . createElement ( 'i' ) ;
793
+ this . manipulationDOM [ id + 'Icon' ] . className = 'vis-button__icon' ;
794
+ this . manipulationDOM [ id + 'Icon' ] . innerHTML = svgIcon ? svgIcon : '' ;
778
795
this . manipulationDOM [ id + 'Div' ] . appendChild ( this . manipulationDOM [ id + 'Label' ] ) ;
796
+ // do prepend icon before text
797
+ this . manipulationDOM [ id + 'Label' ] . insertBefore ( this . manipulationDOM [ id + 'Icon' ] , this . manipulationDOM [ id + 'Label' ] . firstChild ) ;
779
798
return this . manipulationDOM [ id + 'Div' ] ;
780
799
}
781
800
@@ -786,7 +805,7 @@ class ManipulationSystem {
786
805
*/
787
806
_createDescription ( label ) {
788
807
this . manipulationDiv . appendChild (
789
- this . _createButton ( 'description' , 'vis-button vis-none' , label )
808
+ this . _createButton ( 'description' , 'vis-button vis-none' , '' , label )
790
809
) ;
791
810
}
792
811
0 commit comments