-
-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add expansion/collapse animations for cards
Key changes: - Add animation for card opening/collapse. Other supporting changes: - Remove card expansion panel to its own component for easier maintainability and better separation of concerns. - Use real DOM element instead of &:before pseudo class for showing expansion arrow. This increases by maintainability by separating its code and concerns. - TODO: When one card is expanded and others is also expanded then the transition sucks.
- Loading branch information
1 parent
be7a886
commit b042b36
Showing
5 changed files
with
186 additions
and
104 deletions.
There are no files selected for viewing
90 changes: 90 additions & 0 deletions
90
src/presentation/components/Scripts/View/Cards/CardExpansionPanel.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
<template> | ||
<div class="card__expander"> | ||
<div class="card__expander__close-button"> | ||
<FlatButton | ||
icon="xmark" | ||
@click="collapse()" | ||
/> | ||
</div> | ||
<div class="card__expander__content"> | ||
<ScriptsTree | ||
:category-id="categoryId" | ||
:has-top-padding="false" | ||
/> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import { | ||
defineComponent, | ||
} from 'vue'; | ||
import FlatButton from '@/presentation/components/Shared/FlatButton.vue'; | ||
import ScriptsTree from '@/presentation/components/Scripts/View/Tree/ScriptsTree.vue'; | ||
export default defineComponent({ | ||
components: { | ||
ScriptsTree, | ||
FlatButton, | ||
}, | ||
props: { | ||
categoryId: { | ||
type: Number, | ||
required: true, | ||
}, | ||
}, | ||
emits: { | ||
/* eslint-disable @typescript-eslint/no-unused-vars */ | ||
onCollapse: () => true, | ||
/* eslint-enable @typescript-eslint/no-unused-vars */ | ||
}, | ||
setup(_, { emit }) { | ||
function collapse() { | ||
emit('onCollapse'); | ||
} | ||
return { | ||
collapse, | ||
}; | ||
}, | ||
}); | ||
</script> | ||
|
||
<style scoped lang="scss"> | ||
@use "@/presentation/assets/styles/main" as *; | ||
$expanded-margin-top : 30px; | ||
.card__expander { | ||
transition: all 0.2s ease-in-out; | ||
position: relative; | ||
background-color: $color-primary-darker; | ||
color: $color-on-primary; | ||
display: flex; | ||
align-items: center; | ||
flex-direction: column; | ||
margin-top: $expanded-margin-top; | ||
.card__expander__content { | ||
display: flex; | ||
justify-content: center; | ||
word-break: break-word; | ||
max-width: 100%; // Prevents horizontal expansion of inner content (e.g., when a code block is shown) | ||
width: 100%; // Expands the container to fill available horizontal space, enabling alignment of child items. | ||
} | ||
.card__expander__close-button { | ||
font-size: $font-size-absolute-large; | ||
align-self: flex-end; | ||
margin-right: 0.25em; | ||
@include clickable; | ||
color: $color-primary-light; | ||
@include hover-or-touch { | ||
color: $color-primary; | ||
} | ||
} | ||
} | ||
</style> |
24 changes: 24 additions & 0 deletions
24
src/presentation/components/Scripts/View/Cards/CardExpansionPanelArrow.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<template> | ||
<div class="arrow-container"> | ||
<div class="arrow" /> | ||
</div> | ||
</template> | ||
|
||
<style scoped lang="scss"> | ||
@use "@/presentation/assets/styles/main" as *; | ||
$arrow-size : 15px; | ||
.arrow-container { | ||
position: relative; | ||
.arrow { | ||
position: absolute; | ||
left: calc(50% - $arrow-size * 1.5); | ||
top: calc(1.5 * $arrow-size); | ||
border: solid $color-primary-darker; | ||
border-width: 0 $arrow-size $arrow-size 0; | ||
padding: $arrow-size; | ||
transform: rotate(-135deg); | ||
} | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.