Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion src/popover/utils.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, expect, it } from 'vitest';

import { calculateWindowAdjustment, getIndexOfItem, getNextItem, getPrevItem } from './utils';
import { calculateWindowAdjustment, getIndexOfItem, getNextItem, getPopoverPosition, getPrevItem } from './utils';

describe('popover utilities', () => {
it('navigates only relative to ion-item elements', () => {
Expand Down Expand Up @@ -31,4 +31,28 @@ describe('popover utilities', () => {
checkSafeAreaRight: true,
});
});

it.each([
{ isRTL: false, side: 'start' as const, left: 60, originX: 'right' },
{ isRTL: false, side: 'end' as const, left: 140, originX: 'left' },
{ isRTL: true, side: 'start' as const, left: 140, originX: 'left' },
{ isRTL: true, side: 'end' as const, left: 60, originX: 'right' },
])('maps the logical $side side in RTL=$isRTL', ({ isRTL, side, left, originX }) => {
const trigger = document.createElement('button');
trigger.getBoundingClientRect = () => ({
top: 20,
left: 100,
width: 40,
height: 30,
right: 140,
bottom: 50,
x: 100,
y: 20,
toJSON: () => ({}),
});

expect(
getPopoverPosition(isRTL, 40, 20, 'trigger', side, 'start', { top: 0, left: 0, originX: 'left', originY: 'top' }, trigger),
).toMatchObject({ left, originX });
});
});
22 changes: 16 additions & 6 deletions src/styles/structured-list.scss
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,16 @@ $groups: ion-item-group, ion-reorder-group, ion-accordion-group, ion-radio-group
font-size: 0.76rem;
line-height: 1.06rem;
font-weight: 400;
margin: 8px 16px 4px 0;
margin-block: 8px 4px;
margin-inline: 0 16px;

&:not(.ion-color) {
--color: var(--ion-color-medium-tint);
}
} @else {
font-size: 0.9rem;
margin: 8px 16px 4px 0;
margin-block: 8px 4px;
margin-inline: 0 16px;
}
}
}
Expand Down Expand Up @@ -158,6 +160,10 @@ $groups: ion-item-group, ion-reorder-group, ion-accordion-group, ion-radio-group
padding: 32px 16px 16px;
transform: translateX(5px);

&:dir(rtl) {
transform: translateX(-5px);
}

/**
* ion-header.header-collapse-condenseを使って、スクロールによってHeaderを変化させるトリック
*/
Expand Down Expand Up @@ -255,7 +261,7 @@ $groups: ion-item-group, ion-reorder-group, ion-accordion-group, ion-radio-group
}

ion-text[slot='end']#{$d} {
padding-left: 8px;
padding-inline-start: 8px;
}

&.item-disabled {
Expand All @@ -280,21 +286,25 @@ $groups: ion-item-group, ion-reorder-group, ion-accordion-group, ion-radio-group
}

& > ion-note#{$d} {
margin-block: 8px;
margin-inline: calc(var(--ion-safe-area-left, 0) + $outer-note-inset) calc(var(--ion-safe-area-right, 0) + $outer-note-inset);

&:dir(rtl) {
margin-inline: calc(var(--ion-safe-area-right, 0) + $outer-note-inset) calc(var(--ion-safe-area-left, 0) + $outer-note-inset);
}

@if $is-ios27 {
font-size: 0.76rem;
line-height: 1.06rem;
font-weight: 400;
display: block;
margin: 8px calc(var(--ion-safe-area-right, 0) + $outer-note-inset) 8px calc(var(--ion-safe-area-left, 0) + $outer-note-inset);

&:not(.ion-color) {
--color: var(--ion-color-medium-tint);
}
} @else {
--color: var(--ion-color-medium-tint);
font-size: 0.9rem;
display: block;
margin: 8px calc(var(--ion-safe-area-right, 0) + $outer-note-inset) 8px calc(var(--ion-safe-area-left, 0) + $outer-note-inset);
}
}
}