Skip to content

Commit 67cb098

Browse files
committed
Migrate all components to the new version with minor fixes
1 parent 31e25af commit 67cb098

File tree

21 files changed

+180
-22
lines changed

21 files changed

+180
-22
lines changed

src/components/AppProvider/AppProvider.vue

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,13 @@ onMounted(() => {
6969
navigator.userAgent.includes('Version/16.2') ||
7070
navigator.userAgent.includes('Version/16.3'));
7171
72-
if (isSafari16) {
72+
const isMobileApp16 =
73+
navigator.userAgent.includes('Shopify Mobile/iOS') &&
74+
(navigator.userAgent.includes('OS 16_1') ||
75+
navigator.userAgent.includes('OS 16_2') ||
76+
navigator.userAgent.includes('OS 16_3'));
77+
78+
if (isSafari16 || isMobileApp16) {
7379
document.documentElement.classList.add(
7480
'Polaris-Safari-16-Font-Optical-Sizing-Patch',
7581
);
@@ -126,6 +132,7 @@ function measureScrollbars() {
126132
document.body.removeChild(parentEl);
127133
}
128134
135+
provide('themeName', themeName); // TODO: This should be reactive
129136
provide('theme', getTheme(themeName.value)); // TODO: This should be reactive
130137
provide('features', props.features ?? {});
131138
provide('i18n', new I18n(props.i18n));

src/components/BlockStack/types.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ export interface BlockStackProps {
2525
inlineAlign?: InlineAlign;
2626
/** The spacing between children */
2727
gap?: Gap;
28-
/** HTML id attribute */
29-
id?: string;
3028
/** Reverse the render order of child items
3129
* @default false
3230
*/

src/components/BulkActions/BulkActions.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ div(
2222
@click="paginatedSelectAllAction.onAction",
2323
) {{ paginatedSelectAllAction.content }}
2424

25-
div(:class="styles.BulkActionsPromotedActionsWrapper")
25+
div(v-if="selectMode", :class="styles.BulkActionsPromotedActionsWrapper")
2626
InlineStack(gap="100", blockAlign="center")
2727
div(:class="styles.BulkActionsOuterLayout")
2828
//- measurerMarkup

src/components/BulkActions/components/BulkActionButton/BulkActionButton.vue

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22
div(:class="styles.BulkActionButton", ref="bulkActionButton")
33
template(v-if="isActivatorForMoreActionsPopover")
44
Tooltip(
5-
preferred-position="above",
5+
preferred-position="below",
66
:content="content",
77
)
88
Button(
99
:size="size",
1010
:external="external",
1111
:url="url",
12+
:tone="destructive ? 'critical' : undefined",
1213
:disclosure="disclosure && showContentInButton",
1314
:accessibility-label="isActivatorForMoreActionsPopover ? content : accessibilityLabel",
1415
:disabled="disabled",
@@ -20,6 +21,7 @@ div(:class="styles.BulkActionButton", ref="bulkActionButton")
2021
:size="size",
2122
:external="external",
2223
:url="url",
24+
:tone="destructive ? 'critical' : undefined",
2325
:disclosure="disclosure && showContentInButton",
2426
:accessibility-label="isActivatorForMoreActionsPopover ? content : accessibilityLabel",
2527
:disabled="disabled",
@@ -37,7 +39,7 @@ import {
3739
Tooltip,
3840
} from '@/components';
3941
import type { ButtonProps } from '@/components/Button/types';
40-
import type { DisableableAction } from '@/utilities/types';
42+
import type { DestructableAction, DisableableAction } from '@/utilities/types';
4143
import MenuHorizontalIcon from '@icons/MenuHorizontalIcon.svg';
4244
import styles from '@polaris/components/BulkActions/BulkActions.module.css';
4345
@@ -48,7 +50,7 @@ export type BulkActionButtonProps = {
4850
handleMeasurement?(width: number): void;
4951
showContentInButton?: boolean;
5052
size?: Extract<ButtonProps['size'], 'micro' | 'medium'>;
51-
} & DisableableAction;
53+
} & DisableableAction & DestructableAction;
5254
5355
const props = defineProps<BulkActionButtonProps>();
5456
const emits = defineEmits<{

src/components/BulkActions/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export type BulkActionsProps = {
3333
buttonSize?: Extract<ButtonProps['size'], 'micro' | 'medium'>;
3434
/** Label for the bulk actions */
3535
label?: string;
36-
/** @deprecated List is in a selectable state. No longer needed due to removal of Transition */
36+
/** List is in a selectable state. Will only render the bulk actions when `true` */
3737
selectMode?: boolean;
3838
/** @deprecated Used for forwarding the ref. Use `ref` prop instead */
3939
innerRef?: Ref<any>;

src/components/Button/Button.vue

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ UnstyledButton(
1717
Icon(v-else-if="icon", :source="loading ? 'placeholder' : icon")
1818
span(
1919
v-if="hasChildren",
20-
:class="removeUnderline ? styles.removeUnderline : ''",
20+
as="span",
21+
:variant="size === 'large' || hasPlainText ? 'bodyMd' : 'bodySm'",
22+
:fontWeight="textFontWeight",
2123
:key="disabled ? 'text-disabled' : 'text'"
2224
)
2325
slot
@@ -35,6 +37,7 @@ import { classNames, variationName } from '@/utilities/css';
3537
import type { VueNode } from '@/utilities/types';
3638
import useI18n from '@/use/useI18n';
3739
import { useHasSlot } from '@/use/useHasSlot';
40+
import { useBreakpoints } from '@/use/useBreakpoints';
3841
import type { ButtonProps } from './types';
3942
import { Spinner, Icon } from '@/components';
4043
import { UnstyledButton } from '../UnstyledButton';
@@ -56,6 +59,9 @@ const attrs = useAttrs();
5659
const i18n = useI18n();
5760
const { hasSlot } = useHasSlot();
5861
62+
const breakpoints = useBreakpoints();
63+
const { mdUp } = breakpoints.value;
64+
5965
const props = withDefaults(defineProps<ButtonProps>(), {
6066
size: 'medium',
6167
textAlign: 'center',
@@ -76,7 +82,18 @@ const listeners = computed(() => {
7682
7783
return eventBindings;
7884
});
85+
const hasPlainText = computed(() => ['plain', 'monochromePlain'].includes(props.variant));
86+
const textFontWeight = computed(() => {
87+
if (hasPlainText.value) {
88+
return 'regular';
89+
}
7990
91+
if (props.variant === 'primary') {
92+
return mdUp ? 'medium' : 'semibold';
93+
}
94+
95+
return 'medium';
96+
});
8097
const hasChildren = computed(() => hasSlot(slots.default));
8198
const isDisabled = computed(() => props.disabled || props.loading);
8299
const className = computed(() => classNames(
Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,31 @@
11
<template lang="pug">
2-
div(:class="styles.FooterHelp")
2+
div(:class="styles.FooterHelp", :style="style")
33
div(:class="styles.Text")
44
slot
55
</template>
66

77
<script setup lang="ts">
8-
import { type VNode } from 'vue';
8+
import { computed, type VNode } from 'vue';
99
import { type VueNode } from '@/utilities/types';
1010
import styles from '@polaris/components/FooterHelp/FooterHelp.module.css';
1111
12+
type FooterHelpProps = {
13+
/** Horizontal alignment of the component
14+
* @default 'center'
15+
*/
16+
align?: 'start' | 'center' | 'end';
17+
}
18+
19+
const props = withDefaults(defineProps<FooterHelpProps>(), {
20+
align: 'center',
21+
});
22+
1223
const slots = defineSlots<{
1324
/** The content to display inside the layout. */
1425
default?: (_?: VueNode) => VNode[];
1526
}>();
27+
28+
const style = computed(() => ({
29+
'--pc-footer-help-align': props.align,
30+
}));
1631
</script>

src/components/Icon/Icon.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ span(:class="className")
1111
:class="styles.Svg",
1212
:focusable="false",
1313
:aria-hidden="true",
14+
:viewBox="mdDown ? '1 1 18 18' : undefined",
1415
)
1516

1617
div(
@@ -32,6 +33,7 @@ import { computed } from 'vue';
3233
import { classNames, variationName } from '@/utilities/css';
3334
import { Text } from '@/components';
3435
import type { IconSource } from '@/utilities/types';
36+
import { useBreakpoints } from '@/use/useBreakpoints';
3537
import type {
3638
Tone,
3739
Source,
@@ -49,6 +51,9 @@ export type IconProps = {
4951
5052
const props = defineProps<IconProps>();
5153
54+
const breakpoints = useBreakpoints();
55+
const { mdDown } = breakpoints.value;
56+
5257
const sourceType = computed<Source>(() => {
5358
// Because of svgLoader so we need to check if the source is a function AND an object
5459
const functionTypes = ['function', 'object']

src/components/IndexTable/components/Row/Row.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ const rowClassName = computed(() => classNames(
9696
props.disabled && styles['TableRow-disabled'],
9797
props.tone && styles[variationName('tone', props.tone)],
9898
!selectable.value &&
99+
!currentInstance?.vnode.props?.onClick &&
99100
!primaryLinkElement.value &&
100101
styles['TableRow-unclickable'],
101102
));
@@ -118,7 +119,10 @@ const handleInteraction = (event: MouseEvent | KeyboardEvent) => {
118119
};
119120
120121
const handleRowClick = (event: MouseEvent) => {
121-
if ((props.disabled || !selectable.value) && !primaryLinkElement.value) {
122+
if ((props.disabled || !selectable.value)
123+
&& !currentInstance?.vnode.props?.onClick
124+
&& !primaryLinkElement.value
125+
) {
122126
return;
123127
}
124128

src/components/Portal/Portal.vue

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ teleport(
33
v-if="container",
44
:to="PORTAL_CONTAINER_ID",
55
)
6-
div(:data-portal-id="portalId")
6+
ThemeProvider(
7+
:theme="isThemeNameLocal(themeName) ? themeName : themeNameDefault",
8+
:data-portal-id="portalId",
9+
)
710
slot
811
</template>
912

@@ -12,8 +15,12 @@ import {
1215
computed,
1316
onMounted,
1417
} from 'vue';
18+
import { themeNameDefault } from '@shopify/polaris-tokens';
1519
import useId from '@/use/useId';
1620
import usePortalsManager from '@/use/usePortalsManager';
21+
import { useThemeName } from '@/use/useTheme';
22+
import { ThemeProvider } from '@/components/ThemeProvider';
23+
import { isThemeNameLocal } from '@/components/ThemeProvider/utils';
1724
1825
const PORTAL_CONTAINER_ID = '#PolarisPortalsContainer';
1926
@@ -32,6 +39,7 @@ const emits = defineEmits<PortalEmits>();
3239
// This variable to make sure that Portal is within AppProvider
3340
const container = usePortalsManager();
3441
const uniqueId = useId();
42+
const themeName = useThemeName();
3543
3644
const portalId = computed(() => {
3745
return props.idPrefix

0 commit comments

Comments
 (0)