Skip to content

Commit

Permalink
version change
Browse files Browse the repository at this point in the history
  • Loading branch information
gaudyb committed Apr 11, 2024
1 parent b6102d0 commit a0a8be1
Show file tree
Hide file tree
Showing 5 changed files with 112 additions and 111 deletions.
5 changes: 5 additions & 0 deletions .yarn/versions/27234325.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
releases:
"@essex/components": minor

declined:
- essex-toolkit-stories
94 changes: 46 additions & 48 deletions packages/components/src/Footer/Footer.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,68 +1,66 @@
import { useMicrosoftConsentBanner } from './../../../hooks/src/useMicrosoftConsentBanner.js'

Check failure on line 1 in packages/components/src/Footer/Footer.stories.tsx

View workflow job for this annotation

GitHub Actions / build (18.x)

missing header
/*!
* Copyright (c) Microsoft. All rights reserved.
* Licensed under the MIT license. See LICENSE file in the project.
*/
import {
Footer,
} from './Footer.js'
import { Footer } from './Footer.js'
import type { FooterProps } from './Footer.types.js'
import { useMicrosoftConsentBanner } from './../../../hooks/src/useMicrosoftConsentBanner.js'
import { useTheme } from '@fluentui/react'

const meta = {
title: '@essex:components/Footer',
component: Footer
component: Footer,
}

export default meta

const PrimaryComponent: React.FC<FooterProps> = (args) => {
const theme = useTheme()
const CONSENT_CONF = {
theme: theme.isInverted ? 'dark' : 'light',
elementId: 'cookie-banner',
onChange: (c: any) => console.log('consent changed', c),
}
const theme = useTheme()
const CONSENT_CONF = {
theme: theme.isInverted ? 'dark' : 'light',
elementId: 'cookie-banner',
onChange: (c: any) => console.log('consent changed', c),
}

const [, manageConsent] = useMicrosoftConsentBanner(CONSENT_CONF)
const [, manageConsent] = useMicrosoftConsentBanner(CONSENT_CONF)

return (
<div style={{ display: 'flex', alignItems: 'center' }}>
<Footer
{...args}
links={[
{
name: 'Privacy & Cookies',
href: ' https://go.microsoft.com/fwlink/?LinkId=521839',
},
{
name: 'Consumer Health Privacy',
href: 'https://go.microsoft.com/fwlink/?LinkId=2259814',
},
{
name: 'Manage Cookies',
onClick:{manageConsent},
hide: true
},
{
name: 'Terms of Use',
href: 'https://go.microsoft.com/fwlink/?LinkID=206977',
},
{
name: 'Trademarks',
href: 'https://www.microsoft.com/trademarks',
},
{
name: `©️ ${new Date().getFullYear()} Microsoft`,
href: 'https://www.microsoft.com',
},
{
name: 'Github',
href: 'https://github.com/microsoft/essex-toolkit',
},
]}
/>
</div>
<div style={{ display: 'flex', alignItems: 'center' }}>
<Footer
{...args}
links={[
{
name: 'Privacy & Cookies',
href: ' https://go.microsoft.com/fwlink/?LinkId=521839',
},
{
name: 'Consumer Health Privacy',
href: 'https://go.microsoft.com/fwlink/?LinkId=2259814',
},
{
name: 'Manage Cookies',
onClick: { manageConsent },
hide: true,
},
{
name: 'Terms of Use',
href: 'https://go.microsoft.com/fwlink/?LinkID=206977',
},
{
name: 'Trademarks',
href: 'https://www.microsoft.com/trademarks',
},
{
name: `©️ ${new Date().getFullYear()} Microsoft`,
href: 'https://www.microsoft.com',
},
{
name: 'Github',
href: 'https://github.com/microsoft/essex-toolkit',
},
]}
/>
</div>
)
}

Expand Down
118 changes: 58 additions & 60 deletions packages/components/src/Footer/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,22 @@
* Copyright (c) Microsoft. All rights reserved.
* Licensed under the MIT license. See LICENSE file in the project.
*/
import { Text } from '@fluentui/react'
import { Text, useTheme } from '@fluentui/react'
import type { FC } from 'react'
import { memo, useMemo } from 'react'
import { useTheme } from '@fluentui/react'

import type {
FooterProps,
FooterLinkDetails,
} from './Footer.types.js'
import { Container, LinkA, LinkDiv } from './Footer.styles.js'
import type { FooterLinkDetails, FooterProps } from './Footer.types.js'

export const defaultFooterLinks: Array<FooterLinkDetails> = [
{
name: 'Privacy & Cookies',
href: ' https://go.microsoft.com/fwlink/?LinkId=521839',
},
{
name: 'Consumer Health Privacy',
href: 'https://go.microsoft.com/fwlink/?LinkId=2259814',
},
{
name: 'Consumer Health Privacy',
href: 'https://go.microsoft.com/fwlink/?LinkId=2259814',
},
{
name: 'Terms of Use',
href: 'https://go.microsoft.com/fwlink/?LinkID=206977',
Expand All @@ -34,74 +30,76 @@ export const defaultFooterLinks: Array<FooterLinkDetails> = [
name: `©️ ${new Date().getFullYear()} Microsoft`,
href: 'https://www.microsoft.com',
},
{
{
name: 'Github',
href: 'https://github.com/microsoft/essex-toolkit',
},
]

export const Footer: FC<FooterProps> = memo(
function Footer({
links = defaultFooterLinks,
}) {
const theme = useTheme()
export const Footer: FC<FooterProps> = memo(function Footer({
links = defaultFooterLinks,
}) {
const theme = useTheme()

// override link color to provide subtle footer while still meeting contrast requirements
const style = useMemo(
() => ({ color: theme.palette.neutralSecondary }),
[theme],
)
// override link color to provide subtle footer while still meeting contrast requirements
const style = useMemo(
() => ({ color: theme.palette.neutralSecondary }),
[theme],
)

const footerLinks = useMemo(() => {
return links.map(({ name, href }, i) => {
return (
<Link key={name} divider={i !== 0} style={style} href={href}>
{name}
</Link>
)
})
}, [links])
const footerLinks = useMemo(() => {
return links.map(({ name, href }, i) => {
return (
<Link key={name} divider={i !== 0} style={style} href={href}>
{name}
</Link>
)
})
}, [links, style])

return (
<Container>
{footerLinks}
</Container>
)
},
)
return <Container>{footerLinks}</Container>
})

const Link: FC<
React.PropsWithChildren<{
href?: string
id?: string
hide?: boolean
divider: boolean
divider: boolean
className?: string
style?: React.CSSProperties
onClick?: () => void
}>
> = memo(function Link({ id, className, divider, hide, children, href, style, onClick }) {
> = memo(function Link({
id,
className,
divider,
hide,
children,
href,
style,
onClick,
}) {
return (href == null || href === '') && (hide == null || hide === false) ? (
<>
{divider && <Text variant='tiny'>|</Text>}
<LinkDiv style={style} className={className} id={id} onClick={onClick}>
{children}
</LinkDiv>
</>

<>
{divider && <Text variant='tiny'>|</Text>}
<LinkDiv style={style} className={className} id={id} onClick={onClick}>
{children}
</LinkDiv>
</>
) : (
<>
{divider && <Text variant='tiny'>|</Text>}
<LinkA
target='_blank'
rel='noreferrer'
href={href}
style={style}
className={className}
id={id}
>
{children}
</LinkA>
</>
<>
{divider && <Text variant='tiny'>|</Text>}
<LinkA
target='_blank'
rel='noreferrer'
href={href}
style={style}
className={className}
id={id}
>
{children}
</LinkA>
</>
)
})
})
4 changes: 2 additions & 2 deletions packages/components/src/Footer/Footer.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/**
* @public
*/
export type FooterLinkDetails = { name: string; href: string}
export type FooterLinkDetails = { name: string; href: string }

/**
* Defaults to {
Expand Down Expand Up @@ -56,4 +56,4 @@ export type FooterLinkProps = {
onClick?: () => void
divider?: boolean
hide?: boolean
}
}
2 changes: 1 addition & 1 deletion packages/components/src/Footer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
* Licensed under the MIT license. See LICENSE file in the project.
*/
export * from './Footer.js'
export * from './Footer.types.js'
export * from './Footer.types.js'

0 comments on commit a0a8be1

Please sign in to comment.