Skip to content

Commit

Permalink
docs: fix responsiviness sedge docs (#503)
Browse files Browse the repository at this point in the history
  • Loading branch information
stdevMac authored Feb 10, 2025
1 parent 07eb7e0 commit c92d5e4
Show file tree
Hide file tree
Showing 6 changed files with 579 additions and 55 deletions.
179 changes: 159 additions & 20 deletions docs/src/components/BashScript/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
import React, { useState } from 'react';
import React, { useState, useEffect } from 'react';
import { Copy, Check } from 'lucide-react';
import styled from '@emotion/styled';

const BashCommand = ({ command }) => {
const [copied, setCopied] = useState(false);
const [isMobile, setIsMobile] = useState(false);

useEffect(() => {
const checkMobile = () => {
setIsMobile(window.innerWidth <= 480);
};

checkMobile();
window.addEventListener('resize', checkMobile);

return () => window.removeEventListener('resize', checkMobile);
}, []);

const copyToClipboard = async () => {
try {
Expand All @@ -14,29 +27,155 @@ const BashCommand = ({ command }) => {
}
};

const Container = styled.div`
margin: 1rem 0;
border-radius: 8px;
overflow: hidden;
background-color: var(--ifm-background-surface-color);
border: 1px solid var(--ifm-color-emphasis-300);
width: 100%;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
@media (max-width: 768px) {
margin: 0.875rem 0;
}
@media (max-width: 480px) {
margin: 0.75rem 0;
border-radius: 6px;
}
`;

const Content = styled.div`
display: flex;
align-items: center;
justify-content: space-between;
padding: 1rem;
gap: 0.75rem;
position: relative;
@media (max-width: 768px) {
padding: 0.875rem;
}
@media (max-width: 480px) {
padding: 0.75rem 0.625rem;
}
@media (max-width: 768px) {
padding: 0.875rem 1rem;
}
@media (max-width: 480px) {
padding: 0.75rem;
}
`;

const CodeBlock = styled.div`
flex: 1;
overflow-x: auto;
-webkit-overflow-scrolling: touch;
position: relative;
/* Custom scrollbar */
::-webkit-scrollbar {
height: 4px;
}
::-webkit-scrollbar-track {
background: var(--ifm-color-emphasis-100);
border-radius: 2px;
}
::-webkit-scrollbar-thumb {
background: var(--ifm-color-emphasis-300);
border-radius: 2px;
}
pre {
margin: 0;
padding: 0;
min-width: min-content;
}
code {
font-family: var(--ifm-font-family-monospace);
font-size: 0.9375rem;
color: var(--ifm-color-emphasis-900);
white-space: pre;
padding-bottom: ${isMobile ? '0.25rem' : '0'}; /* Space for scrollbar on mobile */
@media (max-width: 768px) {
font-size: 0.875rem;
}
@media (max-width: 480px) {
font-size: 0.8125rem;
}
}
`;

const CopyButton = styled.button`
display: flex;
align-items: center;
justify-content: center;
background: none;
border: none;
padding: 0.5rem;
cursor: pointer;
border-radius: 4px;
transition: all 0.2s ease;
min-width: 36px;
height: 36px;
flex-shrink: 0;
&:hover {
background-color: var(--ifm-color-emphasis-200);
}
&:active {
background-color: var(--ifm-color-emphasis-300);
transform: scale(0.95);
}
svg {
width: 18px;
height: 18px;
transition: transform 0.2s ease;
@media (max-width: 480px) {
width: 16px;
height: 16px;
}
}
@media (max-width: 480px) {
padding: 0.375rem;
min-width: 32px;
height: 32px;
}
`;

return (
<div className="bash-command-container">
<div className="bash-command-content">
<div className="bash-command-code">
<Container>
<Content>
<CodeBlock>
<pre>
<code>{command}</code>
</pre>
</div>
<div>
<button
onClick={copyToClipboard}
className="bash-command-button"
aria-label="Copy to clipboard"
>
{copied ? (
<Check className="bash-command-icon" style={{ color: 'green' }} />
) : (
<Copy className="bash-command-icon" style={{ color: 'gray' }} />
)}
</button>
</div>
</div>
</div>
</CodeBlock>
<CopyButton
onClick={copyToClipboard}
aria-label="Copy to clipboard"
>
{copied ? (
<Check style={{ color: 'var(--ifm-color-success)' }} />
) : (
<Copy style={{ color: 'var(--ifm-color-emphasis-600)' }} />
)}
</CopyButton>
</Content>
</Container>
);
};

Expand Down
88 changes: 75 additions & 13 deletions docs/src/components/Header/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,41 +8,67 @@ import InstallCommand from "../InstallCommand";
export function Header() {
const HeaderWrapper = styled.div`
width: 100%;
//background-image: url('/img/background-image.jpg');
background-size: cover;
background-position: center;
position: relative;
padding: 0 1rem;
//&::before {
// content: '';
// position: absolute;
// top: 0;
// left: 0;
// right: 0;
// bottom: 0;
// background: rgba(0, 0, 0, 0.7); // Darker overall overlay
//}
@media (max-width: 768px) {
padding: 0 0.75rem;
}
@media (max-width: 480px) {
padding: 0 0.5rem;
}
`;


const HeaderContent = styled.header`
position: relative;
padding: 4rem 0;
padding: 4rem 1rem;
text-align: center;
display: flex;
flex-direction: column;
align-items: center;
max-width: var(--ifm-container-width);
margin: 0 auto;
color: var(--ifm-font-color-base);
@media (max-width: 1024px) {
padding: 3rem 1rem;
}
@media (max-width: 768px) {
padding: 2.5rem 0.75rem;
}
@media (max-width: 480px) {
padding: 2rem 0.5rem;
}
`;

const Title = styled.h1`
font-weight: 600;
font-size: 3rem;
margin-top: 1rem;
margin-bottom: 1rem;
margin: 1.5rem 0;
text-align: center;
max-width: 800px;
line-height: 1.2;
@media (max-width: 1024px) {
font-size: 2.5rem;
margin: 1.25rem 0;
}
@media (max-width: 768px) {
font-size: 2rem;
margin: 1rem 0;
}
@media (max-width: 480px) {
font-size: 1.75rem;
margin: 0.875rem 0;
}
`;

const SearchWrapper = styled.div`
Expand All @@ -51,12 +77,48 @@ export function Header() {
max-width: 600px;
display: flex;
justify-content: center;
@media (max-width: 768px) {
margin-top: 1.5rem;
max-width: 100%;
padding: 0 1rem;
}
@media (max-width: 480px) {
margin-top: 1.25rem;
padding: 0 0.5rem;
}
/* Style the search input to be more responsive */
:global(.navbar__search-input) {
width: 100%;
max-width: none;
font-size: 1rem;
padding: 0.75rem 1rem;
@media (max-width: 480px) {
font-size: 0.9375rem;
padding: 0.625rem 0.875rem;
}
}
`;

return (
<HeaderWrapper>
<HeaderContent>
<ThemedImage
style={{
width: 'auto',
height: 'auto',
maxWidth: '80%',
maxHeight: '120px',
'@media (max-width: 768px)': {
maxHeight: '100px',
},
'@media (max-width: 480px)': {
maxHeight: '80px',
},
}}
sources={{
dark: useBaseUrl('/img/Sedge_Horizontal_Light.svg'),
light: useBaseUrl('/img/Sedge_Horizontal_Dark.svg'),
Expand Down
Loading

0 comments on commit c92d5e4

Please sign in to comment.