Skip to content

Commit

Permalink
[ui] Fix CodeLocationSource in flex container (#24422)
Browse files Browse the repository at this point in the history
## Summary & Motivation

The CodeLocationSource button is stretching when rendered in a flex
container. Wrap it in a div.

Created a storybook example to demo the different possibilities of the
component.

<img width="209" alt="Screenshot 2024-09-11 at 16 44 00"
src="https://github.com/user-attachments/assets/6f736caf-915b-4993-b7f1-1f6ab74475c8">

## How I Tested These Changes

Storybook

## Changelog

- [ ] `BUGFIX` [ui] Fixed broken code location URL button rendering.
  • Loading branch information
hellendag authored Sep 11, 2024
1 parent 53ae8c5 commit 54a8201
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,15 @@ export const CodeLocationSource = ({metadata}: {metadata: Metadata[]}) => {
const {type, url} = urlValue;

return (
<ExternalAnchorButton
href={url.toString()}
icon={<Icon name={type === 'github-url' ? 'github' : 'gitlab'} />}
rightIcon={<Icon name="open_in_new" />}
>
View repo
</ExternalAnchorButton>
<div>
<ExternalAnchorButton
href={url.toString()}
icon={<Icon name={type === 'github-url' ? 'github' : 'gitlab'} />}
rightIcon={<Icon name="open_in_new" />}
>
View repo
</ExternalAnchorButton>
</div>
);
};

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import {Box} from '@dagster-io/ui-components';
import {Meta} from '@storybook/react';

import {CodeLocationSource} from '../CodeLocationSource';

// eslint-disable-next-line import/no-default-export
export default {
title: 'CodeLocationSource',
component: CodeLocationSource,
} as Meta;

export const Default = () => {
return (
<Box flex={{direction: 'column', gap: 20}}>
<CodeLocationSource metadata={[]} />
<CodeLocationSource metadata={[{key: 'url', value: 'not-a-url'}]} />
<CodeLocationSource
metadata={[{key: 'url', value: 'https://github.com/dagster-io/dagster'}]}
/>
<CodeLocationSource metadata={[{key: 'url', value: 'https://gitlab.com/foo-bar'}]} />
<CodeLocationSource metadata={[{key: 'url', value: 'https://zombo.com'}]} />
</Box>
);
};

1 comment on commit 54a8201

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deploy preview for dagit-core-storybook ready!

✅ Preview
https://dagit-core-storybook-j79yinq7c-elementl.vercel.app

Built with commit 54a8201.
This pull request is being automatically deployed with vercel-action

Please sign in to comment.