Skip to content

Commit

Permalink
Merge pull request #56 from KSJaay/v0.6.3
Browse files Browse the repository at this point in the history
v0.6.3 - Adds new compact mode
  • Loading branch information
KSJaay authored Nov 20, 2024
2 parents fef4ade + d991231 commit 392ac24
Show file tree
Hide file tree
Showing 27 changed files with 319 additions and 185 deletions.
38 changes: 0 additions & 38 deletions app/components/home/monitor/layout/compact.jsx

This file was deleted.

35 changes: 0 additions & 35 deletions app/components/home/monitor/layout/compact.scss

This file was deleted.

43 changes: 43 additions & 0 deletions app/components/home/monitor/layout/compact/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import './styles.scss';

// import dependencies
import PropTypes from 'prop-types';
import Monitor from '../../../../../pages/monitor';

const MonitorCompact = ({ children, monitor_id }) => {
return (
<div className="home-monitor-compact">
<div
className="home-monitor-table"
style={{
backgroundColor: 'var(--accent-900)',
justifyContent: 'flex-start',
borderRadius: 'var(--radius-md)',
}}
>
<div className="home-monitor-table-container-compact">
<div className="home-monitor-table-header">Name</div>
</div>

<div className="home-monitor-compact-table-content">{children}</div>
</div>
<div className="home-monitor-compact-content">
{monitor_id && <Monitor monitor_id={monitor_id} />}

{!monitor_id && (
<div className="home-monitor-compact-content-empty">
Select a monitor
</div>
)}
</div>
</div>
);
};

MonitorCompact.displayName = 'MonitorCompact';
MonitorCompact.propTypes = {
children: PropTypes.node,
monitor_id: PropTypes.string,
};

export default MonitorCompact;
48 changes: 48 additions & 0 deletions app/components/home/monitor/layout/compact/monitor.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// import dependencies
import PropTypes from 'prop-types';
import { useNavigate } from 'react-router-dom';

// import local files
import { monitorPropType } from '../../../../../../shared/utils/propTypes';
import classNames from 'classnames';

const MonitorCompactItem = ({ monitor = {}, isActive, setActive }) => {
const navigate = useNavigate();

const { name, url } = monitor;

const classes = classNames('home-monitor-name-compact', {
'home-monitor-name-compact-active': isActive,
});

return (
<div
className="home-monitor-container-compact"
onClick={() => {
if (window.innerWidth <= 1024) {
return navigate(`/monitor/${monitor.monitorId}`);
}

setActive(monitor.monitorId);
}}
id={`monitor-${monitor.name}`}
>
<div className={classes}>
<div>{name}</div>
<div style={{ fontSize: '0.85rem', color: 'var(--accent-200)' }}>
{url}
</div>
</div>
</div>
);
};

MonitorCompactItem.displayName = 'MonitorCompactItem';

MonitorCompactItem.propTypes = {
monitor: monitorPropType.isRequired,
isActive: PropTypes.bool,
setActive: PropTypes.func,
};

export default MonitorCompactItem;
81 changes: 81 additions & 0 deletions app/components/home/monitor/layout/compact/styles.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
@use '../../../../../styles/pxToRem.scss' as *;
@use '../../../../../styles/breakpoints.scss' as *;

.home-monitor-compact {
display: grid;
grid-template-columns: 350px 1fr;
background-color: var(--accent-800);
overflow: hidden;
}

.home-monitor-compact-content {
display: flex;
justify-content: center;
overflow: auto;
overflow-x: hidden;
border-radius: var(--radius-md);
margin-bottom: 1rem;
}

.home-monitor-container-compact {
width: 100%;
background-color: var(--accent-900);
padding: pxToRem(4) pxToRem(8);
transition: var(--transition-base);

&:hover {
cursor: pointer;

.home-monitor-name-compact {
color: var(--primary-500);
background-color: var(--accent-800);
}
}
}

.home-monitor-name-compact {
display: flex;
flex-direction: column;
justify-content: center;
color: var(--font-color);
font-size: var(--font-lg);
padding: pxToRem(4) pxToRem(8);
border-radius: var(--radius-sm);
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
transition: var(--transition-base);

&-active {
color: var(--primary-500);
background-color: var(--accent-800);
}
}

.home-monitor-uptime-compact {
flex: 1;
display: flex;
flex-direction: column;
justify-content: center;
color: var(--font-color);
font-size: var(--font-lg);
}

.home-monitor-compact-content-empty {
display: flex;
justify-content: center;
align-items: center;
height: 100%;
font-size: var(--font-2xl);
color: var(--accent-200);
}

@include tablet {
.home-monitor-compact {
grid-template-columns: 1fr;
}

.home-monitor-compact-content {
display: none;
}
}
27 changes: 2 additions & 25 deletions app/components/home/monitor/layout/table.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,11 @@ import './table.scss';

// import dependencies
import PropTypes from 'prop-types';
import classNames from 'classnames';

const MonitorTable = ({ layout, children }) => {
const isCompact = layout === 'compact';

const classes = classNames({
'home-monitor-table-container-list': !isCompact,
'home-monitor-table-container-compact': isCompact,
});

if (isCompact) {
return (
<div className="home-monitor-table">
<div className={classes}>
<div className="home-monitor-table-header">Name</div>
<div className="home-monitor-table-header">Ping</div>
<div className="home-monitor-table-header">Uptime</div>
</div>

<div className="home-monitor-table-content">{children}</div>
</div>
);
}

const MonitorTable = ({ children }) => {
return (
<div className="home-monitor-table">
<div className={classes}>
<div className="home-monitor-table-container-list">
<div className="home-monitor-table-header">Name</div>
<div className="home-monitor-table-header">Ping</div>
<div className="home-monitor-table-header-uptime">Uptime</div>
Expand All @@ -42,7 +20,6 @@ const MonitorTable = ({ layout, children }) => {
MonitorTable.displayName = 'MonitorTable';

MonitorTable.propTypes = {
layout: PropTypes.oneOf(['compact', 'list']),
children: PropTypes.node,
};

Expand Down
10 changes: 10 additions & 0 deletions app/components/home/monitor/layout/table.scss
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
border-radius: var(--radius-md) var(--radius-md) 0 0;
transition: var(--transition-base);
border-bottom: 1px solid var(--accent-700);
margin-bottom: 0.25rem;

div {
display: flex;
Expand All @@ -55,6 +56,11 @@
}
}

.home-monitor-compact-table-content {
overflow: auto;
height: calc(100vh - 220px);
}

@include tablet {
.home-monitor-table-container-list {
grid-template-columns: 1fr 100px 100px;
Expand All @@ -77,4 +83,8 @@
.home-monitor-table-header-uptime {
display: none;
}

.home-monitor-compact-table-content {
height: calc(100vh - 280px);
}
}
Loading

0 comments on commit 392ac24

Please sign in to comment.