-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[SharedUX] Migrate PageTemplate > SolutionNavAvatar #128386
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
4c02548
[SharedUX] Migrate PageTemplate > SolutionNavAvatar
372840f
Fix comment
88fba5a
Renaming component
6b47699
Fix folder structure
44c5039
Fix storybook
b65b050
Style fix
0b6709c
Merge branch 'main' into page-template-3-2
kibanamachine 710e3a0
Design review
bbacf5e
Fix invalid URL path
1c616d5
Fix url path
ec00f9a
Fix url path
a6edc84
Merge branch 'page-template-3-2' of github.com:majagrubic/kibana into…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
.../kbn-shared-ux-components/src/solution_avatar/__snapshots__/solution_avatar.test.tsx.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
packages/kbn-shared-ux-components/src/solution_avatar/assets/texture.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions
9
packages/kbn-shared-ux-components/src/solution_avatar/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
export { KibanaSolutionAvatar } from './solution_avatar'; |
14 changes: 14 additions & 0 deletions
14
packages/kbn-shared-ux-components/src/solution_avatar/solution_avatar.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
.kbnSolutionAvatar { | ||
@include euiBottomShadowSmall; | ||
|
||
&--xxl { | ||
@include euiBottomShadowMedium; | ||
@include size(100px); | ||
line-height: 100px; | ||
border-radius: 100px; | ||
display: inline-block; | ||
background: $euiColorEmptyShade url('/assets/texture.svg') no-repeat; | ||
background-size: cover, 125%; | ||
text-align: center; | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
packages/kbn-shared-ux-components/src/solution_avatar/solution_avatar.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import React from 'react'; | ||
import { KibanaSolutionAvatar, KibanaSolutionAvatarProps } from './solution_avatar'; | ||
|
||
export default { | ||
title: 'Solution Avatar', | ||
description: 'A wrapper around EuiAvatar, specifically to stylize Elastic Solutions', | ||
}; | ||
|
||
type Params = Pick<KibanaSolutionAvatarProps, 'size' | 'name'>; | ||
|
||
export const PureComponent = (params: Params) => { | ||
return <KibanaSolutionAvatar {...params} />; | ||
}; | ||
|
||
PureComponent.argTypes = { | ||
name: { | ||
control: 'text', | ||
defaultValue: 'Kibana', | ||
}, | ||
size: { | ||
control: 'radio', | ||
options: ['s', 'm', 'l', 'xl', 'xxl'], | ||
defaultValue: 'xxl', | ||
}, | ||
}; |
18 changes: 18 additions & 0 deletions
18
packages/kbn-shared-ux-components/src/solution_avatar/solution_avatar.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
import { KibanaSolutionAvatar } from './solution_avatar'; | ||
|
||
describe('KibanaSolutionAvatar', () => { | ||
test('renders', () => { | ||
const component = shallow(<KibanaSolutionAvatar name="Solution" iconType="logoElastic" />); | ||
expect(component).toMatchSnapshot(); | ||
}); | ||
}); |
44 changes: 44 additions & 0 deletions
44
packages/kbn-shared-ux-components/src/solution_avatar/solution_avatar.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
import './solution_avatar.scss'; | ||
|
||
import React from 'react'; | ||
import classNames from 'classnames'; | ||
|
||
import { DistributiveOmit, EuiAvatar, EuiAvatarProps } from '@elastic/eui'; | ||
|
||
export type KibanaSolutionAvatarProps = DistributiveOmit<EuiAvatarProps, 'size'> & { | ||
/** | ||
* Any EuiAvatar size available, or `xxl` for custom large, brand-focused version | ||
*/ | ||
size?: EuiAvatarProps['size'] | 'xxl'; | ||
}; | ||
|
||
/** | ||
* Applies extra styling to a typical EuiAvatar; | ||
* The `name` value will be appended to 'logo' to configure the `iconType` unless `iconType` is provided. | ||
*/ | ||
export const KibanaSolutionAvatar = ({ className, size, ...rest }: KibanaSolutionAvatarProps) => { | ||
return ( | ||
// @ts-ignore Complains about ExclusiveUnion between `iconSize` and `iconType`, but works fine | ||
<EuiAvatar | ||
className={classNames( | ||
'kbnSolutionAvatar', | ||
{ | ||
[`kbnSolutionAvatar--${size}`]: size, | ||
}, | ||
className | ||
)} | ||
color="plain" | ||
size={size === 'xxl' ? 'xl' : size} | ||
iconSize={size} | ||
iconType={`logo${rest.name}`} | ||
{...rest} | ||
/> | ||
); | ||
}; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any way we can utilize home's
FeatureCatalogueSolution
type here to require a Solution to pass to thename
andiconType
props of EuiAvatar? I really like the idea of strongly typing this usage to only be allowed specifically for solutions.Something like:
Then:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the idea, but unfortunately, that interface is only exported from the plugin, and we can't be adding dependencies on plugins here. But we have a tracking issue for that, so can add it there and change once (if 😬 ) the types are exported in a package.