Skip to content

Commit

Permalink
fix: display of readonly rating on android (#81)
Browse files Browse the repository at this point in the history
  • Loading branch information
quentinderoubaix authored Aug 16, 2023
1 parent a63d7dd commit 44be31d
Show file tree
Hide file tree
Showing 7 changed files with 166 additions and 20 deletions.
14 changes: 11 additions & 3 deletions angular/demo/src/app/samples/rating/readonly.route.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
import {AgnosUIAngularModule} from '@agnos-ui/angular';
import {Component} from '@angular/core';
import {Component, inject} from '@angular/core';
import heartFill from '!raw-loader!bootstrap-icons/icons/heart-fill.svg';
import {DomSanitizer} from '@angular/platform-browser';

@Component({
standalone: true,
imports: [AgnosUIAngularModule],
template: `
<ng-template auRatingStar #custom let-fill="fill">
<span class="star" [class.full]="fill === 100"> <span class="half" [style.width.%]="fill">&hearts;</span>&hearts;</span>
<span class="star" [class.full]="fill === 100">
<span class="half" [style.width.%]="fill" [innerHTML]="sanitizer.bypassSecurityTrustHtml(heartFill)"></span>
<span [innerHTML]="sanitizer.bypassSecurityTrustHtml(heartFill)"></span>
</span>
</ng-template>
<au-rating class="rating-custom" [rating]="3.64" [slotStar]="custom" [readonly]="true" [maxRating]="5" ariaLabel="readonly rating" />
`,
})
export default class ReadonlyRatingComponent {}
export default class ReadonlyRatingComponent {
readonly sanitizer = inject(DomSanitizer);
readonly heartFill = heartFill;
}
File renamed without changes.
7 changes: 6 additions & 1 deletion common/demo.scss
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,13 @@ main {
.star {
position: relative;
display: inline-block;
font-size: 300%;
font-size: 2.5rem;
color: #d3d3d3;
svg {
width: 1em;
height: 1em;
padding-right: 0.1rem;
}
}

.full {
Expand Down
2 changes: 1 addition & 1 deletion e2e/rating/rating.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ test.describe.parallel(`Rating tests`, () => {
text: '3.64 out of 5',
disabled: null,
readonly: 'true',
stars: ['♥♥', '♥♥', '♥♥', '♥♥', '♥♥'],
stars: ['', '', '', '', ''],
classes: expectedClasses,
};
expect(await ratingPO.state()).toEqual(expectedState);
Expand Down
150 changes: 140 additions & 10 deletions e2e/samplesMarkup.e2e-spec.ts-snapshots/rating-readonly.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,35 @@
class="half"
style="width: 100%;"
>
"♥"
<svg
class="bi bi-heart-fill"
fill="currentColor"
height="16"
viewBox="0 0 16 16"
width="16"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M8 1.314C12.438-3.248 23.534 4.735 8 15-7.534 4.736 3.562-3.248 8 1.314z"
fill-rule="evenodd"
/>
</svg>
</span>
<span>
<svg
class="bi bi-heart-fill"
fill="currentColor"
height="16"
viewBox="0 0 16 16"
width="16"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M8 1.314C12.438-3.248 23.534 4.735 8 15-7.534 4.736 3.562-3.248 8 1.314z"
fill-rule="evenodd"
/>
</svg>
</span>
"♥"
</span>
</span>
<span
Expand All @@ -53,9 +79,35 @@
class="half"
style="width: 100%;"
>
"♥"
<svg
class="bi bi-heart-fill"
fill="currentColor"
height="16"
viewBox="0 0 16 16"
width="16"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M8 1.314C12.438-3.248 23.534 4.735 8 15-7.534 4.736 3.562-3.248 8 1.314z"
fill-rule="evenodd"
/>
</svg>
</span>
<span>
<svg
class="bi bi-heart-fill"
fill="currentColor"
height="16"
viewBox="0 0 16 16"
width="16"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M8 1.314C12.438-3.248 23.534 4.735 8 15-7.534 4.736 3.562-3.248 8 1.314z"
fill-rule="evenodd"
/>
</svg>
</span>
"♥"
</span>
</span>
<span
Expand All @@ -74,9 +126,35 @@
class="half"
style="width: 100%;"
>
"♥"
<svg
class="bi bi-heart-fill"
fill="currentColor"
height="16"
viewBox="0 0 16 16"
width="16"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M8 1.314C12.438-3.248 23.534 4.735 8 15-7.534 4.736 3.562-3.248 8 1.314z"
fill-rule="evenodd"
/>
</svg>
</span>
<span>
<svg
class="bi bi-heart-fill"
fill="currentColor"
height="16"
viewBox="0 0 16 16"
width="16"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M8 1.314C12.438-3.248 23.534 4.735 8 15-7.534 4.736 3.562-3.248 8 1.314z"
fill-rule="evenodd"
/>
</svg>
</span>
"♥"
</span>
</span>
<span
Expand All @@ -95,9 +173,35 @@
class="half"
style="width: 64%;"
>
"♥"
<svg
class="bi bi-heart-fill"
fill="currentColor"
height="16"
viewBox="0 0 16 16"
width="16"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M8 1.314C12.438-3.248 23.534 4.735 8 15-7.534 4.736 3.562-3.248 8 1.314z"
fill-rule="evenodd"
/>
</svg>
</span>
<span>
<svg
class="bi bi-heart-fill"
fill="currentColor"
height="16"
viewBox="0 0 16 16"
width="16"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M8 1.314C12.438-3.248 23.534 4.735 8 15-7.534 4.736 3.562-3.248 8 1.314z"
fill-rule="evenodd"
/>
</svg>
</span>
"♥"
</span>
</span>
<span
Expand All @@ -116,9 +220,35 @@
class="half"
style="width: 0%;"
>
"♥"
<svg
class="bi bi-heart-fill"
fill="currentColor"
height="16"
viewBox="0 0 16 16"
width="16"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M8 1.314C12.438-3.248 23.534 4.735 8 15-7.534 4.736 3.562-3.248 8 1.314z"
fill-rule="evenodd"
/>
</svg>
</span>
<span>
<svg
class="bi bi-heart-fill"
fill="currentColor"
height="16"
viewBox="0 0 16 16"
width="16"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M8 1.314C12.438-3.248 23.534 4.735 8 15-7.534 4.736 3.562-3.248 8 1.314z"
fill-rule="evenodd"
/>
</svg>
</span>
"♥"
</span>
</span>
</div>
Expand Down
7 changes: 3 additions & 4 deletions react/demo/app/samples/rating/Readonly.route.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type {StarContext} from '@agnos-ui/core';
import {Rating} from '@agnos-ui/react';
import heartFill from 'bootstrap-icons/icons/heart-fill.svg?raw';

const RatingDemo = () => {
return (
Expand All @@ -19,10 +20,8 @@ const RatingDemo = () => {
};
return (
<span className={starClassname.join(' ')}>
<span className="half" style={styles}>
&hearts;
</span>
&hearts;
<span className="half" style={styles} dangerouslySetInnerHTML={{__html: heartFill}}></span>
<span dangerouslySetInnerHTML={{__html: heartFill}}></span>
</span>
);
}}
Expand Down
6 changes: 5 additions & 1 deletion svelte/demo/samples/rating/Readonly.route.svelte
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
<script lang="ts">
import {Rating} from '@agnos-ui/svelte';
import heartFill from 'bootstrap-icons/icons/heart-fill.svg?raw';
</script>

<Rating className="rating-custom" rating={3.64} readonly={true} maxRating={5} ariaLabel="readonly rating">
<span slot="star" let:fill let:index class="star" class:full={fill === 100}>
<span class="half" style:width={fill + '%'}>&hearts;</span>&hearts;
<!-- eslint-disable-next-line svelte/no-at-html-tags -->
<span class="half" style:width={fill + '%'}>{@html heartFill}</span>
<!-- eslint-disable-next-line svelte/no-at-html-tags -->
<span>{@html heartFill}</span>
</span>
</Rating>

0 comments on commit 44be31d

Please sign in to comment.