Skip to content

Commit

Permalink
Add a @centered argument to the AuLoader component
Browse files Browse the repository at this point in the history
The loader is centered by default but this doesn't always look correctly for some use-cases. The `@centered` argument allows you to op-out of the default centering in case you need it.
  • Loading branch information
Windvis committed Feb 29, 2024
1 parent 01dfc48 commit 25c6a25
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
11 changes: 10 additions & 1 deletion addon/components/au-loader.gts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export interface AuLoaderSignature {
Args: {
inline?: boolean;
hideMessage?: boolean;
centered?: boolean;
// Deprecated arguments
disableMessage?: boolean;
message?: string;
Expand All @@ -49,9 +50,17 @@ export default class AuLoader extends Component<AuLoaderSignature> {
return this.args.message || 'Aan het laden';
}

get centered() {
if (typeof this.args.centered === 'undefined' || this.args.centered) {
return 'au-u-text-center';
}

return '';
}

<template>
{{#if (has-block)}}
<div class="au-c-loader au-u-text-center" role="status" ...attributes>
<div class="au-c-loader {{this.centered}}" role="status" ...attributes>
<LoadingAnimation />
{{#if @inline}}
<span
Expand Down
6 changes: 6 additions & 0 deletions stories/5-components/Notifications/AuLoader.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ export default {
control: 'boolean',
description: 'Hide the loading text',
},
centered: {
control: 'boolean',
description: 'Allows you to opt-out of the centered positioning. defaults to `true`',
},
},
parameters: {
layout: 'padded',
Expand All @@ -26,6 +30,7 @@ const Template = (args) => ({
<AuLoader
@inline={{this.inline}}
@hideMessage={{this.hideMessage}}
@centered={{this.centered}}
>{{this.message}}</AuLoader>`,
context: args,
});
Expand All @@ -35,4 +40,5 @@ Component.args = {
message: 'Aan het laden',
inline: false,
hideMessage: false,
centered: true,
};

0 comments on commit 25c6a25

Please sign in to comment.