Skip to content
This repository has been archived by the owner on Aug 29, 2023. It is now read-only.

Commit

Permalink
Merge pull request #231 from smartive-education/feature/MumbleLogo-2
Browse files Browse the repository at this point in the history
feat(MumbleLogo): add logo
  • Loading branch information
tomschall authored Feb 22, 2023
2 parents 5ca952a + 7d9b9fe commit c7160c7
Show file tree
Hide file tree
Showing 8 changed files with 274 additions and 44 deletions.
78 changes: 45 additions & 33 deletions packages/app/pages/includes/navi.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import React from 'react';
import Link from 'next/link';
import { Avatar, NaviButton, Navigation } from '@smartive-education/design-system-component-library-yeahyeahyeah';
import {
Avatar,
MumbleLogo,
NaviButton,
Navigation,
NavigationColumn,
NavigationRow,
} from '@smartive-education/design-system-component-library-yeahyeahyeah';
import { useRouter } from 'next/router';

export default function Navi() {
Expand All @@ -19,38 +26,43 @@ export default function Navi() {
<Link href="./textbox">Textbox</Link>
<Link href="./hashtag">Hashtag</Link>
</div>
<div tw="w-full mb-32">
<Navigation title="Mumble Logo">
<NaviButton
label="Profile"
variant="profile"
href="/profilepage"
legacyBehavior={true}
passHref={true}
linkComponent={Link}
>
<Avatar alt="Small Avatar" src="https://media.giphy.com/media/cfuL5gqFDreXxkWQ4o/giphy.gif" variant="small" />
</NaviButton>
<NaviButton
label="Settings"
variant="default"
icon="settings"
href="/"
legacyBehavior={true}
passHref={true}
linkComponent={Link}
/>
<NaviButton
label="Logout"
variant="default"
icon="logout"
href="/detailview"
legacyBehavior={true}
passHref={true}
linkComponent={Link}
/>
</Navigation>
</div>
<Navigation>
<NavigationColumn>
<Link href="/detailview" title="Startpage" target="_self">
<MumbleLogo isNavigation={true} color="white" alignment="horizontal" />
</Link>
<NavigationRow>
<NaviButton
label="Profile"
variant="profile"
href="/profilepage"
legacyBehavior={true}
passHref={true}
linkComponent={Link}
>
<Avatar alt="Small Avatar" src="https://media.giphy.com/media/cfuL5gqFDreXxkWQ4o/giphy.gif" variant="small" />
</NaviButton>
<NaviButton
label="Settings"
variant="default"
icon="settings"
href="/"
legacyBehavior={true}
passHref={true}
linkComponent={Link}
/>
<NaviButton
label="Logout"
variant="default"
icon="logout"
href="/detailview"
legacyBehavior={true}
passHref={true}
linkComponent={Link}
/>
</NavigationRow>
</NavigationColumn>
</Navigation>
</>
);
}
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;
};
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from './Image';
export * from './ImageContainer';
export * from './MumbleLogo';
Original file line number Diff line number Diff line change
@@ -1,26 +1,31 @@
import React from 'react';
import styled from 'styled-components';
import tw from 'twin.macro';
import type { TmbSpacing } from '../../types/types';
import { BottomSpacing } from '../../styles/Spacing';
import { NavigationContainer } from './NavigationStyles';

export type NavigationProps = {
title: 'Mumble Logo';
children?: React.ReactNode;
mbSpacing?: TmbSpacing;
};

export const Navigation = ({ children }: NavigationProps) => {
export const Navigation = ({ children, mbSpacing }: NavigationProps) => {
return (
<HeaderStyles>
<HeaderStyles mbSpacing={mbSpacing}>
<NavigationStyles>
<NavigationContainer>{children}</NavigationContainer>
</NavigationStyles>
</HeaderStyles>
);
};

const HeaderStyles = tw.header`
w-full
`;
const HeaderStyles = styled.header(() => [
tw`
w-full
`,
BottomSpacing,
]);

const NavigationStyles = styled.nav(() => [
tw`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ export const NavigationContainer = tw.div`
justify-center
items-center
container
px-16
px-0
pl-8
sm:(px-16 pl-0)
`;

export const NavigationColumn = tw.div`
Expand Down
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={() => {}}
/>

```
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';
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
import React, { useState } from 'react';
import { ComponentStory, ComponentMeta } from '@storybook/react';
import NavigationReadme from '../../docs/Navigation.md';
import { Avatar, NaviButton, Navigation, Modal, NavigationContainer, NavigationColumn, NavigationRow } from '../../index';
import {
Avatar,
NaviButton,
Navigation,
Modal,
MumbleLogo,
NavigationContainer,
NavigationColumn,
NavigationRow,
} from '../../index';
import Link from 'next/link';

export default {
title: 'Navigation/Navigation',
component: Navigation,
parameters: { actions: { argTypesRegex: '^on.*' } },
argTypes: {},
} as ComponentMeta<typeof Navigation>;

const Template: ComponentStory<typeof Navigation> = (args) => {
Expand All @@ -19,10 +27,12 @@ const Template: ComponentStory<typeof Navigation> = (args) => {
};

return !open ? (
<Navigation {...args} title="Mumble Logo">
<Navigation {...args}>
<NavigationContainer>
<NavigationColumn>
<div tw="text-slate-white">Logo</div>
<Link href="#" title="Startpage" target="_self">
<MumbleLogo isNavigation={true} color="white" alignment="horizontal" />
</Link>
<NavigationRow>
<NaviButton
label="Profile"
Expand Down

0 comments on commit c7160c7

Please sign in to comment.