Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Look of SelectApp and SelectComponent #15674

Merged
merged 7 commits into from
Feb 19, 2025
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
4 changes: 4 additions & 0 deletions packages/connect-react/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<!-- markdownlint-disable MD024 -->
# Changelog

# [1.0.0-preview.30] - 2025-02-19

- SelectApp and SelectComponent Improvements

# [1.0.0-preview.29] - 2025-02-10

- Fix enableDebugging state update bug
Expand Down
5 changes: 3 additions & 2 deletions packages/connect-react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/connect-react",
"version": "1.0.0-preview.29",
"version": "1.0.0-preview.30",
"description": "Pipedream Connect library for React",
"files": [
"dist"
Expand All @@ -18,7 +18,8 @@
},
"scripts": {
"build": "vite build",
"prepare": "pnpm run build"
"prepare": "pnpm run build",
"watch": "NODE_ENV=development vite build --watch --mode development"
},
"publishConfig": {
"access": "public"
Expand Down
35 changes: 32 additions & 3 deletions packages/connect-react/src/components/SelectApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ export function SelectApp({
} = useApps({
q,
});
const { Option } = components;
const {
Option,
SingleValue,
} = components;
const selectedValue = apps?.find((o) => o.name_slug === value?.name_slug) || null;
return (
<Select
instanceId={instanceId}
Expand All @@ -52,14 +56,39 @@ export function SelectApp({
</div>
</Option>
),
SingleValue: (singleValueProps) => (
<SingleValue {...singleValueProps}>
<div style={{
display: "flex",
gap: 10,
alignItems: "center",
}}>
<img
src={`https://pipedream.com/s.v0/${singleValueProps.data.id}/logo/48`}
style={{
height: 24,
width: 24,
}}
alt={singleValueProps.data.name}
/>
<span style={{
whiteSpace: "nowrap",
}}>
{singleValueProps.data.name}
</span>
</div>
</SingleValue>
),
IndicatorSeparator: () => null,
}}
options={apps || []}
getOptionLabel={(o) => o.name || o.name_slug} // TODO fetch initial value app so we show name
getOptionValue={(o) => o.name_slug}
value={value}
value={selectedValue}
onChange={(o) => onChange?.((o as AppResponse) || undefined)}
onInputChange={(v) => setQ(v)}
onInputChange={(v) => {
if (v) setQ(v)
}}
isLoading={isLoading}
/>
);
Expand Down
11 changes: 6 additions & 5 deletions packages/connect-react/src/components/SelectComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,23 @@ export function SelectComponent({
}: SelectComponentProps) {
const instanceId = useId();
const {
isLoading,
// TODO error
components,
isLoading, components,
} = useComponents({
app: app?.name_slug,
componentType,
});

const selectedValue = components?.find((c) => c.key === value?.key) || null;

return (
<Select
instanceId={instanceId}
className="react-select-container text-sm"
classNamePrefix="react-select"
options={components}
getOptionLabel={(o) => o.name || o.key} // TODO fetch default component so we show name (or just prime correctly in demo)
getOptionLabel={(o) => o.name || o.key}
getOptionValue={(o) => o.key}
value={value}
value={selectedValue}
onChange={(o) => onChange?.((o as V1Component) || undefined)}
isLoading={isLoading}
components={{
Expand Down
2 changes: 1 addition & 1 deletion packages/connect-react/src/hooks/use-apps.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ export const useApps = (input?: GetAppsOpts) => {

return {
...query,
apps: query.data?.data,
apps: query.data?.data || [],
};
};
Loading