Skip to content

Commit

Permalink
feat(core): ✨ update menu transition styles and implementation
Browse files Browse the repository at this point in the history
Same as the previous commit, the transition is now accessible as a CSS variable (transition-menu)
  • Loading branch information
alistair3149 committed Jul 7, 2023
1 parent a7f9c55 commit c7e4517
Show file tree
Hide file tree
Showing 21 changed files with 39 additions and 73 deletions.
9 changes: 6 additions & 3 deletions resources/mixins.less
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,16 @@
// But GTFO instantly when they close the menu
.citizen-card-content-show() {
opacity: 1;
transition: @transition-opacity--transform;
transition: var( --transition-menu );
transition-property: opacity;
will-change: opacity;
}

// Transition animation
.citizen-card-transition() {
transition: @transition-transform, @transition-opacity--transform, @transition-visibility--transform;
will-change: transform, opacity, opacity;
transition: var( --transition-menu );
transition-property: transform, opacity, visibility;
will-change: transform, opacity, visibility;
}

// Header card popups
Expand All @@ -78,6 +80,7 @@
user-select: none;
.citizen-card();
.citizen-card-hide( bottom @position );
.citizen-card-transition();

@media ( min-width: @width-breakpoint-tablet ) {
& when ( @position = left ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@
// TODO: unify the dropdown menu style somewhere
&-panel {
.citizen-header-card( right );
.citizen-card-transition();

&.citizen-pref-panel--active {
.citizen-card-show;
Expand Down
3 changes: 0 additions & 3 deletions resources/skins.citizen.search/skins.citizen.search.less
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
@import '../variables.less';
@import '../mixins.less';

.citizen-typeahead {
position: absolute;
overflow: auto;
Expand Down
3 changes: 2 additions & 1 deletion resources/skins.citizen.styles/common/content.less
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
vertical-align: top; // get rid of that weird bottom gap from inline block

> img {
transition: @transition-transform;
transition: var( --transition-hover );
transition-property: transform;
}

// Add affordance to replace magnify icon
Expand Down
5 changes: 5 additions & 0 deletions resources/skins.citizen.styles/common/cssvariables.less
Original file line number Diff line number Diff line change
Expand Up @@ -178,3 +178,8 @@ html {
--header-card-maxheight: ~'calc( 100vh - var( --space-sm ) * 2 )';
}
}

.citizen-animations-ready {
/* Only apply transition when page is ready for it */
--transition-menu: @transition-menu;
}
2 changes: 0 additions & 2 deletions resources/skins.citizen.styles/common/theme.less
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
@import '../../variables.less';

/**
* Base theme
*/
Expand Down
7 changes: 0 additions & 7 deletions resources/skins.citizen.styles/components/Drawer.less
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,6 @@
}
}

// Wait for first paint before animating
.citizen-animations-ready {
.citizen-drawer__card {
.citizen-card-transition();
}
}

@media ( min-width: @width-breakpoint-tablet ) {
.citizen-drawer {
&__logo img {
Expand Down
3 changes: 2 additions & 1 deletion resources/skins.citizen.styles/components/Header.less
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,8 @@
/* Hide header when scroll down on smaller screen sizes */
@media ( max-width: @width-breakpoint-tablet ) {
.citizen-header {
transition: @transition-transform;
transition: var( --transition-menu );
transition-property: transform;
}

.citizen-scroll--down .citizen-header {
Expand Down
7 changes: 1 addition & 6 deletions resources/skins.citizen.styles/components/Pagetools.less
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
font-size: 0.875rem;
.citizen-card;
.citizen-card-hide( top right );
.citizen-card-transition();
}

// Visible page tools styles
Expand Down Expand Up @@ -239,12 +240,6 @@
}
}

.citizen-animations-ready {
.page-actions__card {
.citizen-card-transition();
}
}

// To avoid more menu from overflow in narrow screen
@media ( max-width: @width-breakpoint-tablet ) {
.page-actions {
Expand Down
7 changes: 1 addition & 6 deletions resources/skins.citizen.styles/components/Search.less
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
gap: 0.25rem;
.citizen-card();
.citizen-card-hide( top center, '', false );
.citizen-card-transition();

.citizen-ui-icon {
width: var( --height-search-bar );
Expand Down Expand Up @@ -104,12 +105,6 @@
}
}

.citizen-animations-ready {
.citizen-search__card {
.citizen-card-transition();
}
}

@media ( max-width: @width-breakpoint-desktop ) {
.citizen-search__card {
z-index: 1; // So that overlay does not cover card
Expand Down
3 changes: 2 additions & 1 deletion resources/skins.citizen.styles/components/StickyHeader.less
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@
@media ( max-width: @width-breakpoint-tablet ) {
.citizen-body-header--sticky {
.mw-body-header {
transition: @transition-transform;
transition: var( --transition-menu );
transition-property: transform;
}

&.citizen-scroll--down {
Expand Down
14 changes: 5 additions & 9 deletions resources/skins.citizen.styles/components/TableOfContents.less
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@
// Move down when site header is hidden
@media ( max-width: ( @width-breakpoint-tablet ) ) {
.citizen-toc {
transition: @transition-transform;
transition: var( --transition-menu );
transition-property: transform;
will-change: transform;
}

Expand Down Expand Up @@ -164,6 +165,7 @@
user-select: none;
.citizen-card;
.citizen-card-hide( bottom right, '', false );
.citizen-card-transition();
}
}

Expand All @@ -189,7 +191,8 @@
pointer-events: auto;
transform: none;
transform-origin: bottom right;
transition: @transition-transform;
transition: var( --transition-menu );
transition-property: transform;

.citizen-ui-icon {
width: 1rem;
Expand Down Expand Up @@ -226,13 +229,6 @@
}
}
}

// Wait for first paint before animating
.citizen-animations-ready {
.citizen-toc__card {
.citizen-card-transition();
}
}
}

@media ( min-width: @width-breakpoint-desktop ) {
Expand Down
6 changes: 0 additions & 6 deletions resources/skins.citizen.styles/components/Usermenu.less
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,3 @@
.citizen-card-show();
}
}

.citizen-animations-ready {
.citizen-userMenu__card {
.citizen-card-transition();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ figure[ typeof~='mw:File/Frame' ] {
max-width: 100%;
height: auto;
contain: strict;
transition: @transition-transform;
transition: var( --transition-hover );
transition-property: transform;

// Prevent constraining image width in tables
table & {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
&.new {
padding: var( --space-sm );
border: 1px dashed var( --border-color-base--darker );
transition: @transition-background, @transition-color;
transition: var( --transition-hover );
transition-property: background, color;

&:hover {
background-color: var( --color-destructive--hover );
Expand Down
17 changes: 1 addition & 16 deletions resources/variables.less
Original file line number Diff line number Diff line change
Expand Up @@ -224,22 +224,7 @@

/* Transitions */
@transition-hover: 150ms cubic-bezier( 0.215,0.61,0.355,1 );

@transition-timing-fast: 100ms;
@transition-timing-slow: 250ms;

@transition-color: color @transition-timing-fast ease;
@transition-background: background @transition-timing-fast ease;
@transition-border-color: border-color @transition-timing-fast ease;
@transition-opacity: opacity @transition-timing-fast ease;

@transition-transform: transform @transition-timing-slow cubic-bezier(0.215,0.61,0.355,1);
// Only used with transform
@transition-opacity--transform: opacity @transition-timing-slow ease;
// Execute after every transition is done
// Need to use with transition-delay: 0ms
@transition-visibility--transform: visibility 0ms linear @transition-timing-slow;
@transition-height: height @transition-timing-slow ease;
@transition-menu: 250ms ease;

/* Shadow */
/* Box shadow */
Expand Down
2 changes: 0 additions & 2 deletions skinStyles/extensions/Cite/ext.cite.styles.less
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
* https://starcitizen.tools
*/

@import '../../../resources/variables.less';

.mw-references-wrap {
margin-top: var( --space-md );
color: var( --color-base );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
* Date: 2023-06-24
*/

@import '../../../resources/variables.less';

.ext-discussiontools-init-replylink-buttons {
.ext-discussiontools-init-replylink {
&-bracket {
Expand Down
6 changes: 4 additions & 2 deletions skinStyles/extensions/MediaSearch/mediasearch.styles.less
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,8 @@
}

img {
transition: @transition-transform;
transition: var( --transition-hover );
transition-property: transform;
}
}

Expand Down Expand Up @@ -677,7 +678,8 @@

&__thumbnail {
border-radius: var( --border-radius--small );
transition: @transition-transform;
transition: var( --transition-hover );
transition-property: transform;
}

&__duration {
Expand Down
6 changes: 4 additions & 2 deletions skinStyles/extensions/MultimediaViewer/mmv.less
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,8 @@
grid-template-areas: 'desc links'
'about about';
grid-template-columns: 2fr 1fr;
transition: @transition-background;
transition: var( --transition-menu );
transition-property: background;

.mw-mmv-untruncated & {
background-color: transparent;
Expand Down Expand Up @@ -607,7 +608,8 @@
border-top-left-radius: var( --border-radius--large );
border-top-right-radius: var( --border-radius--large );
color: #fff;
transition: @transition-background, @transition-color;
transition: var( --transition-menu );
transition-property: background, color;

&.mw-mmv-untruncated {
background-color: var( --color-surface-1 );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@
max-width: 100%;
height: auto;
background-color: var( --color-surface-2 );
transition: @transition-transform;
transition: var( --transition-hover );
transition-property: transform;
}

// Add affordance for full res image
Expand Down

0 comments on commit c7e4517

Please sign in to comment.