Short SnippetCard full linking

This commit is contained in:
Angelos Chalaris
2019-08-27 21:27:05 +03:00
parent 60c9e63036
commit 8315e8aa7d
7 changed files with 25 additions and 16 deletions

View File

@ -96,18 +96,12 @@ const FullCard = ({ snippetData, difficulty, isDarkMode }) => {
> >
{examplesOpen ? <CollapseOpenIcon /> : <CollapseClosedIcon />}Examples {examplesOpen ? <CollapseOpenIcon /> : <CollapseClosedIcon />}Examples
</button> </button>
{/* <ReactCSSTransitionReplace
transitionName='roll-up'
transitionEnterTimeout={300}
transitionLeaveTimeout={300}
> */}
{examplesOpen && ( {examplesOpen && (
<pre <pre
className='section card-examples language-js' className='section card-examples language-js'
dangerouslySetInnerHTML={{ __html: cardExamplesHtml }} dangerouslySetInnerHTML={{ __html: cardExamplesHtml }}
/> />
)} )}
{/* </ReactCSSTransitionReplace> */}
</div> </div>
</div> </div>
); );
@ -122,14 +116,15 @@ const ShortCard = ({
difficulty, difficulty,
}) => { }) => {
return ( return (
<Link
className='clickable-card-wrapper'
to={archived ? `/archive/${snippetData.id}` : `/snippet/${snippetData.id}`}
>
<div className='card short'> <div className='card short'>
<CardCorner difficulty={difficulty} /> <CardCorner difficulty={difficulty} />
<h4 className='card-title'> <h4 className='card-title'>
<Link
to={archived ? `/archive/${snippetData.id}` : `/snippet/${snippetData.id}`}
>
{snippetData.title} {snippetData.title}
</Link>
</h4> </h4>
<div <div
className='card-description' className='card-description'
@ -138,6 +133,7 @@ const ShortCard = ({
}} }}
/> />
</div> </div>
</Link>
); );
}; };

View File

@ -23,7 +23,7 @@ const ArchivePage = props => {
<Shell> <Shell>
<h2 className='page-title'>Archived snippets</h2> <h2 className='page-title'>Archived snippets</h2>
<p className='page-sub-title'>These snippets, while useful and interesting, didn't quite make it into the repository due to either having very specific use-cases or being outdated. However we felt like they might still be useful to some readers, so here they are.</p> <p className='page-sub-title'>These snippets, while useful and interesting, didn't quite make it into the repository due to either having very specific use-cases or being outdated. However we felt like they might still be useful to some readers, so here they are.</p>
<p className='light-sub'>Click on a snippet's name to view its code.</p> <p className='light-sub'>Click on a snippet card to view the snippet.</p>
{posts && {posts &&
posts.map(({ node }) => ( posts.map(({ node }) => (
<SnippetCard <SnippetCard

View File

@ -70,7 +70,7 @@ const IndexPage = props => {
) : ( ) : (
<> <>
<p className='light-sub'> <p className='light-sub'>
Click on a snippet's name to view its code. Click on a snippet card to view the snippet.
</p> </p>
<h2 className='page-sub-title'>Search results</h2> <h2 className='page-sub-title'>Search results</h2>
{searchResults.map(snippet => ( {searchResults.map(snippet => (

View File

@ -65,7 +65,7 @@ const ListPage = props => {
<Shell withIcon={true} isList> <Shell withIcon={true} isList>
<h2 className='page-title'>Snippet List</h2> <h2 className='page-title'>Snippet List</h2>
<p className='light-sub'> <p className='light-sub'>
Click on a snippets name to view its code or a tag name to view all Click on a snippet card to view the snippet or a tag name to view all
snippets in that category. snippets in that category.
</p> </p>
{tags.sort((a,b) => a.localeCompare(b)).map(tag => ( {tags.sort((a,b) => a.localeCompare(b)).map(tag => (

View File

@ -49,7 +49,7 @@ const SearchPage = props => {
setSearchQuery={setSearchQuery} setSearchQuery={setSearchQuery}
defaultValue={props.searchQuery} defaultValue={props.searchQuery}
/> />
<p className='light-sub'>Click on a snippet's name to view its code.</p> <p className='light-sub'>Click on a snippet card to view the snippet.</p>
{/* Display page background or results depending on state */} {/* Display page background or results depending on state */}
{searchQuery.length === 0 ? ( {searchQuery.length === 0 ? (
<> <>

View File

@ -2,6 +2,8 @@
// Cards // Cards
// =================================================== // ===================================================
.card { .card {
backface-visibility: hidden;
will-change: transform;
position: relative; position: relative;
transition: all 0.3s ease; transition: all 0.3s ease;
margin: 1rem 1.25rem; margin: 1rem 1.25rem;
@ -143,3 +145,14 @@
margin-top: 0.375rem; margin-top: 0.375rem;
} }
} }
.clickable-card-wrapper {
&:link, &:visited {
&:hover, &:focus {
text-decoration: none;
.card {
transform: scale(1.025);
}
}
}
}

View File

@ -25,7 +25,7 @@ const TagRoute = props => {
<Meta title={capitalize(tag)} /> <Meta title={capitalize(tag)} />
<Shell> <Shell>
<h2 className='page-title'>{capitalize(tag)}</h2> <h2 className='page-title'>{capitalize(tag)}</h2>
<p className='light-sub'>Click on a snippet's name to view its code.</p> <p className='light-sub'>Click on a snippet card to view the snippet.</p>
{posts && {posts &&
posts.map(({ node }) => ( posts.map(({ node }) => (
<SnippetCard <SnippetCard