Skip to content
This repository has been archived by the owner on Oct 16, 2024. It is now read-only.

Allow adding links to logos #278

Merged
merged 8 commits into from
Jan 11, 2023
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
37 changes: 28 additions & 9 deletions src/components/Home/Header/index.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -28,32 +28,51 @@

&__logos {
grid-area: logos;
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: center;
/**
* User input values.
*/
--grid-layout-gap: 5px;
--grid-column-count: 5;
--grid-item--min-width: 85px;

/**
* Calculated values.
*/
--gap-count: calc(var(--grid-column-count) - 1);
--total-gap-width: calc(var(--gap-count) * var(--grid-layout-gap));
--grid-item--max-width: calc(
(100% - var(--total-gap-width)) / var(--grid-column-count)
);

display: grid;
grid-template-columns: repeat(
auto-fill,
minmax(max(var(--grid-item--min-width), var(--grid-item--max-width)), 1fr)
);
grid-gap: var(--grid-layout-gap);
display: grid;
grid-auto-rows: 1fr;
padding: 10px;
list-style: none;

@media (--md-scr) {
margin: 34px 0 0;
li {
flex-basis: 20%;
}
}

@media (--lg-scr) {
margin: 12px -40px 0;
}
}

&__list {
@apply flex items-center justify-center p-1 rounded-4 md:rounded-6 lg:rounded-8 border border-solid border-transparent;
}

&__logo {
width: var(--width-sm);
margin: 12px 16px 0 0;

@media (--md-scr) {
width: var(--width-md);
margin: 0 auto 10px;
}

@media (--lg-scr) {
Expand Down
116 changes: 77 additions & 39 deletions src/components/Home/Header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,22 @@ import scikitLearnLogo from '../../../images/logo/scikit-learn.png'
import streamlitLogo from '../../../images/logo/streamlit.png'
import tensorflowLogo from '../../../images/logo/tensorflow.png'
import * as styles from './index.module.css'
import Link from '@dvcorg/gatsby-theme-iterative/src/components/Link'

interface ITypedRef {
reset: () => void
destroy: () => void
}

interface ILogo {
src: string
widthSm: number
widthMd: number
widthLg: number
alt: string
link?: string
}

const cliCaptionData: Array<{ bold: string; text: string }> = [
{
bold: 'Save your ML model with a Python call.',
Expand All @@ -53,54 +63,54 @@ const cliCaptionData: Array<{ bold: string; text: string }> = [
}
]

const logosData: Array<{
src: string
widthSm: number
widthMd: number
widthLg: number
alt: string
}> = [
const logosData: Array<ILogo> = [
{
widthSm: 66,
widthMd: 88,
widthLg: 136,
widthSm: 74,
widthMd: 96,
widthLg: 144,
src: fastapiLogo,
alt: 'FastAPI logo'
alt: 'FastAPI logo',
link: '/doc/user-guide/serving/fastapi'
Copy link
Contributor

@aguschin aguschin Dec 29, 2022

Choose a reason for hiding this comment

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

Thanks a lot @yathomasi! I see the border is around logos, can we make them around boxes for logos maybe? Otherwise it looks inconsistent somehow
image
and
image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, great suggestion. I have updated it a bit. Let me how you think.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks! Looks much better! Could we also make them always the same height? Now this is how it looks for me:
image
and
image

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks a ton! Works as expected now! Now I need to get feedback from @iterative/mlem and update "Working with models" page.

},
{
widthSm: 66,
widthMd: 88,
widthLg: 124,
src: dockerLogo,
alt: 'Docker logo'
alt: 'Docker logo',
link: '/doc/user-guide/building/docker'
},
{
widthSm: 66,
widthMd: 88,
widthLg: 124,
src: streamlitLogo,
alt: 'Streamlit logo'
alt: 'Streamlit logo',
link: '/doc/user-guide/serving/streamlit'
},
{
widthSm: 66,
widthMd: 88,
widthLg: 124,
src: herokuLogo,
alt: 'Heroku logo'
alt: 'Heroku logo',
link: '/doc/user-guide/deploying/heroku'
},
{
widthSm: 55,
widthMd: 75,
widthLg: 108,
src: kubernetesLogo,
alt: 'Kubernetes logo'
alt: 'Kubernetes logo',
link: '/doc/user-guide/deploying/kubernetes'
},
{
widthSm: 66,
widthMd: 88,
widthLg: 124,
src: sagemakerLogo,
alt: 'Sagemaker logo'
alt: 'Sagemaker logo',
link: '/doc/user-guide/deploying/sagemaker'
},
{
widthSm: 66,
Expand All @@ -121,14 +131,16 @@ const logosData: Array<{
widthMd: 88,
widthLg: 124,
src: pythonLogo,
alt: 'Python logo'
alt: 'Python logo',
link: '/doc/user-guide/building/pip'
aguschin marked this conversation as resolved.
Show resolved Hide resolved
},
{
widthSm: 66,
widthMd: 78,
widthLg: 110,
src: condaLogo,
alt: 'Conda logo'
alt: 'Conda logo',
link: '/doc/user-guide/building/conda'
},
{
widthSm: 66,
Expand Down Expand Up @@ -163,7 +175,8 @@ const logosData: Array<{
widthMd: 50,
widthLg: 71,
src: scikitLearnLogo,
alt: 'scikit learn logo'
alt: 'scikit learn logo',
link: '/doc/get-started'
},
{
widthSm: 66,
Expand Down Expand Up @@ -191,17 +204,42 @@ const logosData: Array<{
widthMd: 78,
widthLg: 120,
src: numpyLogo,
alt: 'Numpy logo'
alt: 'Numpy logo',
link: '/doc/user-guide/data'
},
{
widthSm: 66,
widthMd: 78,
widthLg: 110,
src: pandasLogo,
alt: 'Pandas logo'
alt: 'Pandas logo',
link: '/doc/user-guide/data'
}
]

const LogoImage = ({
widthSm,
widthMd,
widthLg,
src,
alt,
className
}: ILogo & { className?: string }) => (
<img
alt={alt}
src={src}
className={cn(styles.header__logo, className)}
width={widthMd}
style={
{
'--width-sm': `${widthSm}px`,
'--width-md': `${widthMd}px`,
'--width-lg': `${widthLg}px`
} as React.CSSProperties
}
/>
)

interface ITerminalSlideData {
allTerminalSlide: {
nodes: [{ lines: [{ text: string; promptString: string }] }]
Expand Down Expand Up @@ -369,24 +407,24 @@ const Header: React.FC = () => {
</div>
</div>
<ul className={styles.header__logos}>
{logosData.map(({ widthSm, widthMd, widthLg, src, alt }, i) => (
<li key={i}>
<img
alt={alt}
src={src}
className={styles.header__logo}
width={widthMd}
height={35}
style={
{
'--width-sm': `${widthSm}px`,
'--width-md': `${widthMd}px`,
'--width-lg': `${widthLg}px`
} as React.CSSProperties
}
/>
</li>
))}
{logosData.map((logoDetails, i) =>
logoDetails?.link ? (
<Link
href={logoDetails.link}
key={i}
className={cn(
styles.header__list,
'hover:border-purple-800 active:bg-gray-200 transition-colors'
)}
>
<LogoImage {...logoDetails} />
</Link>
) : (
<li key={i} className={cn(styles.header__list)}>
<LogoImage {...logoDetails} />
</li>
)
)}
Comment on lines +410 to +427
Copy link
Contributor

@rogermparent rogermparent Jan 10, 2023

Choose a reason for hiding this comment

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

Theoretically if any logoDetails were undefined, this would blow up with a weird error as it attempts to spread an undefined logoDetails. That said, that specific scenario is probably not going to happen.

</ul>
</header>
)
Expand Down
Binary file modified src/images/logo/docker.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/images/logo/flyio.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/images/logo/onnx.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/images/logo/python.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/images/logo/rabbitmq.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.