Skip to content

Commit 438d8cd

Browse files
authored
Improve Look of SelectApp and SelectComponent (#15674)
* SelectApp has a SingleValue now with icon * better label when component is selected * cleanup * version/changelog bump * . * linting
1 parent d89efa3 commit 438d8cd

File tree

5 files changed

+46
-11
lines changed

5 files changed

+46
-11
lines changed

packages/connect-react/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
<!-- markdownlint-disable MD024 -->
22
# Changelog
33

4+
# [1.0.0-preview.30] - 2025-02-19
5+
6+
- SelectApp and SelectComponent Improvements
7+
48
# [1.0.0-preview.29] - 2025-02-10
59

610
- Fix enableDebugging state update bug

packages/connect-react/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/connect-react",
3-
"version": "1.0.0-preview.29",
3+
"version": "1.0.0-preview.30",
44
"description": "Pipedream Connect library for React",
55
"files": [
66
"dist"
@@ -18,7 +18,8 @@
1818
},
1919
"scripts": {
2020
"build": "vite build",
21-
"prepare": "pnpm run build"
21+
"prepare": "pnpm run build",
22+
"watch": "NODE_ENV=development vite build --watch --mode development"
2223
},
2324
"publishConfig": {
2425
"access": "public"

packages/connect-react/src/components/SelectApp.tsx

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@ export function SelectApp({
2525
} = useApps({
2626
q,
2727
});
28-
const { Option } = components;
28+
const {
29+
Option,
30+
SingleValue,
31+
} = components;
32+
const selectedValue = apps?.find((o) => o.name_slug === value?.name_slug) || null;
2933
return (
3034
<Select
3135
instanceId={instanceId}
@@ -52,14 +56,39 @@ export function SelectApp({
5256
</div>
5357
</Option>
5458
),
59+
SingleValue: (singleValueProps) => (
60+
<SingleValue {...singleValueProps}>
61+
<div style={{
62+
display: "flex",
63+
gap: 10,
64+
alignItems: "center",
65+
}}>
66+
<img
67+
src={`https://pipedream.com/s.v0/${singleValueProps.data.id}/logo/48`}
68+
style={{
69+
height: 24,
70+
width: 24,
71+
}}
72+
alt={singleValueProps.data.name}
73+
/>
74+
<span style={{
75+
whiteSpace: "nowrap",
76+
}}>
77+
{singleValueProps.data.name}
78+
</span>
79+
</div>
80+
</SingleValue>
81+
),
5582
IndicatorSeparator: () => null,
5683
}}
5784
options={apps || []}
5885
getOptionLabel={(o) => o.name || o.name_slug} // TODO fetch initial value app so we show name
5986
getOptionValue={(o) => o.name_slug}
60-
value={value}
87+
value={selectedValue}
6188
onChange={(o) => onChange?.((o as AppResponse) || undefined)}
62-
onInputChange={(v) => setQ(v)}
89+
onInputChange={(v) => {
90+
if (v) setQ(v)
91+
}}
6392
isLoading={isLoading}
6493
/>
6594
);

packages/connect-react/src/components/SelectComponent.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,23 @@ export function SelectComponent({
2020
}: SelectComponentProps) {
2121
const instanceId = useId();
2222
const {
23-
isLoading,
24-
// TODO error
25-
components,
23+
isLoading, components,
2624
} = useComponents({
2725
app: app?.name_slug,
2826
componentType,
2927
});
28+
29+
const selectedValue = components?.find((c) => c.key === value?.key) || null;
30+
3031
return (
3132
<Select
3233
instanceId={instanceId}
3334
className="react-select-container text-sm"
3435
classNamePrefix="react-select"
3536
options={components}
36-
getOptionLabel={(o) => o.name || o.key} // TODO fetch default component so we show name (or just prime correctly in demo)
37+
getOptionLabel={(o) => o.name || o.key}
3738
getOptionValue={(o) => o.key}
38-
value={value}
39+
value={selectedValue}
3940
onChange={(o) => onChange?.((o as V1Component) || undefined)}
4041
isLoading={isLoading}
4142
components={{

packages/connect-react/src/hooks/use-apps.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ export const useApps = (input?: GetAppsOpts) => {
1717

1818
return {
1919
...query,
20-
apps: query.data?.data,
20+
apps: query.data?.data || [],
2121
};
2222
};

0 commit comments

Comments
 (0)