This repository has been archived by the owner on Aug 29, 2023. It is now read-only.
generated from ost-cas-fee-adv-22-23/cas-fee-adv-design-system-tpl
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #231 from smartive-education/feature/MumbleLogo-2
feat(MumbleLogo): add logo
- Loading branch information
Showing
8 changed files
with
274 additions
and
44 deletions.
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
113 changes: 113 additions & 0 deletions
113
packages/design-system-component-library-yeahyeahyeah/components/image/MumbleLogo.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,113 @@ | ||
import React, { useState } from 'react'; | ||
import tw, { styled, TwStyle } from 'twin.macro'; | ||
import { MumbleText, MumbleGradient, LogoMumble as Logo } from '../icon/index'; | ||
|
||
export interface IMumbleLogoProps { | ||
color: 'violet' | 'gradient' | 'white'; | ||
alignment: 'horizontal' | 'vertical'; | ||
onLogoClick?: () => void; | ||
isNavigation?: boolean; | ||
} | ||
|
||
export const MumbleLogo: React.FC<IMumbleLogoProps> = ({ | ||
color = 'white', | ||
alignment = 'horizontal', | ||
onLogoClick, | ||
isNavigation = true, | ||
}) => { | ||
const [hover, setHover] = useState(false); | ||
|
||
return ( | ||
<MumbleLogoStyledDiv | ||
alignment={alignment} | ||
onClick={onLogoClick} | ||
onMouseEnter={() => setHover(true)} | ||
onMouseLeave={() => setHover(false)} | ||
> | ||
<StyledLogoMumble color={color} $hover={hover} $navigation={isNavigation} /> | ||
|
||
{color !== 'gradient' ? ( | ||
<StyledMumbleText color={color} $navigation={isNavigation} alignment={alignment} $hover={hover} /> | ||
) : ( | ||
<StyledMumbleGradient $navigation={isNavigation} alignment={alignment} $hover={hover} /> | ||
)} | ||
</MumbleLogoStyledDiv> | ||
); | ||
}; | ||
|
||
type IStyled = { | ||
$hover: boolean; | ||
$navigation: boolean; | ||
color: 'violet' | 'gradient' | 'white'; | ||
alignment: 'horizontal' | 'vertical'; | ||
}; | ||
|
||
type IMumbleLogoStyledDiv = Pick<IStyled, 'alignment'>; | ||
|
||
const MumbleLogoStyledDiv = styled.div(({ alignment }: IMumbleLogoStyledDiv) => [ | ||
tw` | ||
flex | ||
justify-between | ||
items-center | ||
p-0 | ||
cursor-pointer | ||
w-[130px] | ||
sm:w-auto | ||
`, | ||
alignment === 'vertical' && tw`flex-col`, | ||
alignment === 'horizontal' && tw`flex-row`, | ||
]); | ||
|
||
type IStyledLogoMumble = Pick<IStyled, 'color' | '$hover' | '$navigation'>; | ||
|
||
const StyledLogoMumble = styled(Logo)(({ color, $hover, $navigation }: IStyledLogoMumble) => [ | ||
tw`fill-violet-600`, | ||
$navigation === true ? tw`w-48 h-48` : tw`w-64 h-64 `, | ||
IconColor(color, $hover), | ||
]); | ||
|
||
type IStyledMumbleText = Pick<IStyled, 'alignment' | '$navigation' | 'color' | '$hover'>; | ||
|
||
const StyledMumbleText = styled(MumbleText)(({ alignment, $navigation, color, $hover }: IStyledMumbleText) => [ | ||
$navigation === true ? tw`h-[30px] w-[154px]` : tw`h-[48px] w-[246px]`, | ||
TextSvgStyles(alignment, $navigation), | ||
IconColor(color, $hover), | ||
]); | ||
|
||
type IStyledMumbleGradient = Pick<IStyled, 'alignment' | '$navigation' | '$hover'>; | ||
|
||
const StyledMumbleGradient = styled(MumbleGradient)(({ alignment, $navigation }: IStyledMumbleGradient) => [ | ||
$navigation === true ? tw`h-[30px] w-[154px]` : tw`h-[48px] w-[246px]`, | ||
TextSvgStyles(alignment, $navigation), | ||
]); | ||
|
||
const IconColor = (color: string, $hover: boolean) => { | ||
let hoverColor: TwStyle; | ||
let defaultColor: TwStyle; | ||
|
||
switch (color) { | ||
case 'violet': | ||
defaultColor = tw`fill-violet-600`; | ||
hoverColor = tw`fill-slate-white`; | ||
return $hover === true ? hoverColor : defaultColor; | ||
case 'gradient': | ||
defaultColor = tw`fill-violet-600`; | ||
hoverColor = tw`fill-slate-white`; | ||
return $hover === true ? hoverColor : defaultColor; | ||
case 'white': | ||
defaultColor = tw`fill-slate-white`; | ||
hoverColor = tw`fill-slate-300`; | ||
return $hover === true ? hoverColor : defaultColor; | ||
} | ||
return null; | ||
}; | ||
|
||
const TextSvgStyles = (alignment: string, $navigation: boolean) => { | ||
switch (alignment) { | ||
case 'horizontal': | ||
return $navigation === true ? (tw`ml-8 sm:ml-16` as TwStyle) : (tw`ml-8 sm:ml-16 ` as TwStyle); | ||
case 'vertical': | ||
return $navigation === true ? (tw`mt-8` as TwStyle) : (tw`mt-16` as TwStyle); | ||
} | ||
return null; | ||
}; |
1 change: 1 addition & 0 deletions
1
packages/design-system-component-library-yeahyeahyeah/components/image/index.ts
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from './Image'; | ||
export * from './ImageContainer'; | ||
export * from './MumbleLogo'; |
17 changes: 11 additions & 6 deletions
17
packages/design-system-component-library-yeahyeahyeah/components/navigation/Navigation.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
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
42 changes: 42 additions & 0 deletions
42
packages/design-system-component-library-yeahyeahyeah/docs/MumbleLogo.md
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,42 @@ | ||
![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/smartive-education/design-system-component-library-yeahyeahyeah) | ||
# MumbleLogo | ||
## MumbleLogo properties | ||
| Property|Description| | ||
|-|-| | ||
|alignment|Choose *horizontal* for integration in *navbar*. Futher details see [Navigation](./?path=/docs/navigation-navigation--navigation-story)| | ||
|color|*White* is the preferred color for *navbar* integration.| | ||
|isNavigation|A optimized size for MumbleNavigation.| | ||
|onLogoClick|JS-Callback function.| | ||
|
||
## Include MumbleLogo from the component library in your App | ||
|
||
```js | ||
// index.tsx, index.js, index.jsx | ||
|
||
import { MumbleLogo } from "@smartive-education/design-system-component-library-yeahyeahyeah" | ||
|
||
``` | ||
|
||
### MumbleLogo *navigation* snippet | ||
```js | ||
|
||
<MumbleLogo | ||
alignment="horizontal" | ||
color="white" | ||
isNavigation | ||
onLogoClick={() => {}} | ||
/> | ||
|
||
``` | ||
|
||
### MumbleLogo *vertical*, *gradient* example. Can be integrated on *landingpages* | ||
```js | ||
|
||
<MumbleLogo | ||
alignment="horizontal" | ||
color="white" | ||
isNavigation | ||
onLogoClick={() => {}} | ||
/> | ||
|
||
``` |
45 changes: 45 additions & 0 deletions
45
packages/design-system-component-library-yeahyeahyeah/stories/image/MumbleLogo.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,45 @@ | ||
import React from 'react'; | ||
import { ComponentStory, ComponentMeta } from '@storybook/react'; | ||
import { MumbleLogo } from '../../components/image/MumbleLogo'; | ||
import MumbleLogoReadme from '../../docs/MumbleLogo.md'; | ||
|
||
export default { | ||
title: 'Medias/Logo', | ||
component: MumbleLogo, | ||
argTypes: { | ||
alignment: { | ||
control: 'select', | ||
}, | ||
color: { | ||
control: 'select', | ||
}, | ||
isNavigation: { | ||
control: 'boolean', | ||
}, | ||
onLogoClick: { | ||
action: () => 'handleClick', | ||
}, | ||
}, | ||
args: { | ||
alignment: 'vertical', | ||
color: 'violet', | ||
isNavigation: false, | ||
}, | ||
} as ComponentMeta<typeof MumbleLogo>; | ||
|
||
const Template: ComponentStory<typeof MumbleLogo> = (args) => { | ||
return <MumbleLogo {...args} />; | ||
}; | ||
|
||
export const LogoVariants = Template; | ||
|
||
LogoVariants.parameters = { | ||
docs: { | ||
source: { type: 'dynamic' }, | ||
description: { | ||
component: MumbleLogoReadme, | ||
}, | ||
}, | ||
}; | ||
|
||
LogoVariants.storyName = 'Logo'; |
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