Skip to content

Commit 7dac5f2

Browse files
feat: note component for Learning-path
Signed-off-by: rishabhsharma1997 <[email protected]>
1 parent 96a18bb commit 7dac5f2

File tree

5 files changed

+62
-9
lines changed

5 files changed

+62
-9
lines changed

src/custom/Note/Note.tsx

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import { styled } from '@mui/material';
2+
import { FC } from 'react';
3+
4+
interface AlertProps {
5+
type?: 'success' | 'warning' | 'note';
6+
title?: string;
7+
content?: string;
8+
}
9+
10+
const NoteWrapper = styled('div')<NoteWrapperProps>(({ type, theme }) => ({
11+
fontWeight: 500,
12+
background: '#212529',
13+
color: 'inherit',
14+
marginTop: '2rem',
15+
width: '80%',
16+
height: '80%',
17+
marginBottom: '2rem',
18+
padding: '0.5rem 1rem',
19+
borderRadius: 0,
20+
borderStyle: 'solid',
21+
borderColor:
22+
type === 'warning' ? theme.palette.text.warning : theme.palette.background.brand?.default,
23+
borderWidth: '0 0 0 4px'
24+
}));
25+
26+
const NoteHeading = styled('h4')<NoteWrapperProps>(({ type, theme }) => ({
27+
color: type === 'warning' ? theme.palette.text.warning : theme.palette.background.brand?.default,
28+
fontSize: '1.35rem'
29+
}));
30+
31+
const NoteContent = styled('p')(({ theme }) => ({
32+
color: theme.palette.text.inverse
33+
}));
34+
35+
interface NoteWrapperProps {
36+
type: 'success' | 'warning' | 'note';
37+
}
38+
39+
const Note: FC<AlertProps> = ({ type = 'note', title, content }) => {
40+
return (
41+
<NoteWrapper type={type}>
42+
<NoteHeading type={type}>{title}</NoteHeading>
43+
<NoteContent>{content}</NoteContent>
44+
</NoteWrapper>
45+
);
46+
};
47+
48+
export default Note;

src/custom/Note/index.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import Note from './Note';
2+
3+
export { Note };

src/custom/SetupPrerequisite/SetupPrerequisite.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
import React from 'react';
22
import { Card, CardHeader, ContainerCardWrapper, SetupPreReqWrapper } from './style';
33

4-
// const meshery =
5-
// require('../../../assets/images/meshery/icon-only/meshery-logo-light.svg') as string;
6-
// const mesheryOperator =
7-
// require('../../../assets/images/meshery-operator/meshery-operator-dark.svg') as string;
84
interface SetupItem {
95
heading: string;
106
description: string;
11-
Icon: JSX.Element;
7+
Icon: JSX.Element | string; // Updated to allow string (image source)
128
url: string;
139
}
1410
interface SetupPreReqProps {
@@ -22,12 +18,16 @@ const SetupPreReq: React.FC<SetupPreReqProps> = ({ Steps, PrerequisiteLine }) =>
2218
<p>{PrerequisiteLine}</p>
2319
</div>
2420
<ContainerCardWrapper id="Set up">
25-
{Steps.map((item) => {
21+
{Steps.map((item, index) => {
2622
return (
27-
<Card href={item.url} target="_blank">
23+
<Card key={index} href={item.url} target="_blank">
2824
<CardHeader>
2925
<h2>{item.heading}</h2>
30-
{item.Icon}
26+
{typeof item.Icon === 'string' ? (
27+
<img src={item.Icon} alt={item.heading} width={'40px'} height={'40px'} />
28+
) : (
29+
item.Icon
30+
)}
3131
</CardHeader>
3232
<p>{item.description}</p>
3333
</Card>

src/custom/SetupPrerequisite/style.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ const SetupPreReqWrapper = styled('div')({
1313
const ContainerCardWrapper = styled('div')(({ theme }) => ({
1414
display: 'flex',
1515
cursor: 'pointer',
16+
flexDirection: 'row',
17+
flexWrap: 'wrap',
1618
'& a': {
1719
color: theme.palette.text.primary,
1820
margin: '1rem'

src/custom/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ import SearchBar, { SearchBarProps } from './SearchBar';
3636
import { TransferList } from './TransferModal/TransferList';
3737
import { TransferListProps } from './TransferModal/TransferList/TransferList';
3838
import UniversalFilter, { UniversalFilterProps } from './UniversalFilter';
39-
4039
export { CatalogCard } from './CatalogCard';
4140
export { StyledChartDialog } from './ChartDialog';
4241
export { LearningContent } from './LearningContent';
42+
export { Note } from './Note';
4343
export { SetupPreReq } from './SetupPrerequisite';
4444
export { StyledChapter } from './StyledChapter';
4545
export { StyledSearchBar } from './StyledSearchBar';

0 commit comments

Comments
 (0)