@@ -421,6 +421,7 @@ td.row-size {
421421</docs >
422422
423423<script >
424+ import { isLegacy32 } from ' ../../utils/legacy.ts'
424425
425426export default {
426427 name: ' NcButton' ,
@@ -605,6 +606,8 @@ export default {
605606 /**
606607 * The real type to be used for the button, enforces `primary` for pressed state and, if stateful button, any other type for not pressed state
607608 * Otherwise the type property is used.
609+ *
610+ * @return {string}
608611 */
609612 realVariant () {
610613 // Force *primary* when pressed
@@ -625,6 +628,8 @@ export default {
625628
626629 /**
627630 * The HTML button type
631+ *
632+ * @return {string}
628633 */
629634 realType () {
630635 if (typeof this .pressed === ' boolean' ) {
@@ -642,6 +647,13 @@ export default {
642647 return this .type
643648 },
644649
650+ /**
651+ * The variant is one of the tertiary- ones
652+ */
653+ isTertiary () {
654+ return this .realVariant .startsWith (' tertiary' )
655+ },
656+
645657 /**
646658 * The flexbox alignment of the button content
647659 */
@@ -696,6 +708,8 @@ export default {
696708 ' button-vue--text-only' : hasText && ! hasIcon,
697709 ' button-vue--icon-and-text' : hasIcon && hasText,
698710 [` button-vue--vue-${ this .realVariant } ` ]: this .realVariant ,
711+ ' button-vue--legacy' : isLegacy32,
712+ ' button-vue--tertiary' : this .isTertiary ,
699713 ' button-vue--wide' : this .wide ,
700714 [` button-vue--${ this .flexAlignment } ` ]: this .flexAlignment !== ' center' ,
701715 ' button-vue--reverse' : this .isReverseAligned ,
@@ -774,42 +788,47 @@ export default {
774788
775789< style lang= " scss" scoped>
776790.button - vue {
777- // Setup different button sizes
778791 -- button- size: var (-- default- clickable- area);
792+ -- button- inner- size: calc (var (-- button- size) - 4px ); // without the outer border
779793 -- button- radius: var (-- border- radius- element, calc (var (-- button- size) / 2 ));
780- -- button- padding: clamp (var (-- default- grid- baseline), var (-- button- radius), calc (var (-- default- grid- baseline) * 4 ));
781-
782- & -- size- small {
783- -- button- size: var (-- clickable- area- small, 24px );
784- -- button- radius: var (-- border- radius); // make the border radius even smaller for small buttons
785- }
786-
787- & -- size- large {
788- -- button- size: var (-- clickable- area- large, 48px );
789- }
794+ -- button- padding- default: min (calc (var (-- default- grid- baseline) + var (-- button- radius)), calc (var (-- default- grid- baseline) * 4 ));
795+ -- button- padding: var (-- default- grid- baseline) var (-- button- padding- default);
790796
791797 // General styles
798+ // by default use secondary styling
799+ color: var (-- color- primary- element- light- text);
800+ background- color: var (-- color- primary- element- light);
801+ border: 1px solid var (-- color- primary- element- light- hover);
802+ border- bottom- width: 2px ;
803+ border- radius: var (-- button- radius);
804+ box- sizing: border- box;
805+ // adjust position and size
792806 position: relative;
793807 width: fit- content;
794808 overflow: hidden;
795- border: 0 ;
796- padding: 0 ;
797- font- size: var (-- default- font- size);
798- font- weight: bold;
799- min- height: var (-- button- size);
800- min- width: var (-- button- size);
809+ padding- block: 1px 0 ; // center the content as border is 1px top and 2px bottom
810+ padding- inline: var (-- button- padding);
811+ min- height: var (-- button- inner- size);
812+ min- width: var (-- button- inner- size);
813+ // display setup
801814 display: flex;
802815 align- items: center;
803816 justify- content: center;
804-
805- border- radius: var (-- button- radius);
806817 transition- property: color, border- color, background- color;
807818 transition- duration: 0 .1s ;
808819 transition- timing- function: linear;
820+ cursor: pointer;
821+ font- size: var (-- default- font- size);
822+ font- weight: bold;
809823
810- // Default button type
811- color: var (-- color- primary- element- light- text);
812- background- color: var (-- color- primary- element- light);
824+ & -- size- small {
825+ -- button- size: var (-- clickable- area- small, 24px );
826+ -- button- radius: var (-- border- radius); // make the border radius even smaller for small buttons
827+ }
828+
829+ & -- size- large {
830+ -- button- size: var (-- clickable- area- large, 48px );
831+ }
813832
814833 // Cursor pointer on element and all children
815834 & ,
@@ -866,10 +885,10 @@ export default {
866885 }
867886
868887 & __icon {
869- height: var (-- button- size);
870- width: var (-- button- size);
871- min- height: var (-- button- size);
872- min- width: var (-- button- size);
888+ height: var (-- button- inner - size);
889+ width: var (-- button- inner - size);
890+ min- height: var (-- button- inner - size);
891+ min- width: var (-- button- inner - size);
873892 display: flex;
874893 justify- content: center;
875894 align- items: center;
@@ -897,6 +916,7 @@ export default {
897916
898917 // Icon-only button
899918 & -- icon- only {
919+ -- button- padding: clamp (var (-- default- grid- baseline), var (-- button- radius), calc (var (-- default- grid- baseline) * 4 ));
900920 line- height: 1 ;
901921 width: var (-- button- size) ! important;
902922 }
@@ -939,7 +959,9 @@ export default {
939959 // Primary
940960 & -- vue- primary {
941961 background- color: var (-- color- primary- element);
962+ border- color: var (-- color- primary- element- hover);
942963 color: var (-- color- primary- element- text);
964+
943965 & : hover: not (: disabled ) {
944966 background- color: var (-- color- primary- element- hover);
945967 }
@@ -952,27 +974,30 @@ export default {
952974
953975 // Secondary
954976 & -- vue- secondary {
955- color: var (-- color- primary- element- light- text);
956977 background- color: var (-- color- primary- element- light);
978+ border- color: var (-- color- primary- element- light- hover);
979+ color: var (-- color- primary- element- light- text);
980+
957981 & : hover: not (: disabled ) {
958982 color: var (-- color- primary- element- light- text);
959983 background- color: var (-- color- primary- element- light- hover);
960984 }
961985 }
962986
963987 // Tertiary
988+ & -- tertiary,
964989 & -- vue- tertiary {
965- color: var (-- color- main- text);
966990 background- color: transparent;
991+ border- color: transparent;
992+ color: var (-- color- main- text);
993+
967994 & : hover: not (: disabled ) {
968995 background- color: var (-- color- background- hover);
969996 }
970997 }
971998
972999 // Tertiary, no background
9731000 & -- vue- tertiary- no- background {
974- color: var (-- color- main- text);
975- background- color: transparent;
9761001 & : hover: not (: disabled ) {
9771002 background- color: transparent;
9781003 }
@@ -981,7 +1006,6 @@ export default {
9811006 // Tertiary on primary color (like the header)
9821007 & -- vue- tertiary- on- primary {
9831008 color: var (-- color- primary- element- text);
984- background- color: transparent;
9851009
9861010 & : hover: not (: disabled ) {
9871011 background- color: transparent;
@@ -991,7 +1015,9 @@ export default {
9911015 // Success
9921016 & -- vue- success {
9931017 background- color: var (-- color- success);
1018+ border- color: var (-- color- success- hover);
9941019 color: white;
1020+
9951021 & : hover: not (: disabled ) {
9961022 background- color: var (-- color- success- hover);
9971023 }
@@ -1005,7 +1031,9 @@ export default {
10051031 // Warning
10061032 & -- vue- warning {
10071033 background- color: var (-- color- warning);
1034+ border- color: var (-- color- warning- hover);
10081035 color: white;
1036+
10091037 & : hover: not (: disabled ) {
10101038 background- color: var (-- color- warning- hover);
10111039 }
@@ -1019,7 +1047,9 @@ export default {
10191047 // Error
10201048 & -- vue- error {
10211049 background- color: var (-- color- error);
1050+ border- color: var (-- color- error- hover);
10221051 color: white;
1052+
10231053 & : hover: not (: disabled ) {
10241054 background- color: var (-- color- error- hover);
10251055 }
@@ -1029,6 +1059,13 @@ export default {
10291059 background- color: var (-- color- error);
10301060 }
10311061 }
1062+
1063+ // before Nextcloud 32
1064+ & -- legacy {
1065+ -- button- inner- size: var (-- button- size);
1066+ // no border
1067+ border: none;
1068+ }
10321069}
10331070
10341071< / style>
0 commit comments