Ver Fonte

regression fix, better scroll layout

Jimmy Chion há 3 anos atrás
pai
commit
95353506ec
3 ficheiros alterados com 27 adições e 29 exclusões
  1. 0 1
      package-lock.json
  2. 25 18
      src/components/CodeBlocks/Output.tsx
  3. 2 10
      src/pages/index.tsx

+ 0 - 1
package-lock.json

@@ -5,7 +5,6 @@
   "requires": true,
   "packages": {
     "": {
-      "name": "grainy-gradients",
       "version": "0.1.0",
       "dependencies": {
         "@ant-design/icons": "^4.6.3",

+ 25 - 18
src/components/CodeBlocks/Output.tsx

@@ -57,37 +57,41 @@ filter: contrast(${contrast}%) brightness(${brightness}%);
 
   return (
     <Container>
-      <Noise size={size} code={svgString} />
-      <Gradient css={gradientCss} />
-      <FilterContainer>
+      <OutputSection>
+        <Noise size={size} code={svgString} />
+      </OutputSection>
+      <OutputSection>
+        <Gradient css={gradientCss} />
+      </OutputSection>
+      <OutputSection>
         <FilterShadow />
         <Filter css={liveCss} />
-      </FilterContainer>
+      </OutputSection>
     </Container>
   );
 };
 
 export default Output;
 
+// hacking it for essentially flex-direction: column; which does not work
 const Container = styled.div`
-  min-height: 100vh;
+  height: 100vh;
   display: flex;
-  overflow: scroll;
-  flex-direction: column;
-  justify-content: space-evenly;
+  overflow-y: scroll;
+  flex-wrap: wrap;
+  justify-content: center;
   align-items: center;
-  flex-shrink: 1;
 `;
 
-// prettier-ignore
 type NoiseProps = {
-  size: number,
-  code: string
-}
+  size: number;
+  code: string;
+};
+// prettier-ignore
 const Noise = styled.div<NoiseProps>`
   width: ${(p) => p.size}px;
   height: ${(p) => p.size}px;
-  background: url('data:image/svg+xml,${(p) => p.code.replace(symbols, encodeURIComponent)}');
+  background: url("data:image/svg+xml,${(p) => p.code.replace(symbols, encodeURIComponent)}");
   box-shadow: rgb(50 50 93 / 23%) 0px 30px 60px -15px, rgb(0 0 0 / 32%) 0px 18px 36px -18px;
 `;
 
@@ -99,17 +103,20 @@ const Gradient = styled.div<GradientProps>`
   box-shadow: rgb(50 50 93 / 23%) 0px 30px 60px -15px, rgb(0 0 0 / 32%) 0px 18px 36px -18px;
 `;
 
-const FilterContainer = styled.div`
+const OutputSection = styled.div`
   position: relative;
+  display: flex;
+  justify-content: center;
+  width: calc(100vw * 2 / 3);
+  margin: 10px;
 `;
 
 // have to create a new layer, or the filter affects box-shadow
 const FilterShadow = styled.div`
   position: absolute;
   top: 0;
-  left: 0;
-  width: 100%;
-  height: 100%;
+  width: 250px;
+  height: 250px;
   box-shadow: rgb(50 50 93 / 23%) 0px 30px 60px -15px, rgb(0 0 0 / 32%) 0px 18px 36px -18px;
 `;
 

+ 2 - 10
src/pages/index.tsx

@@ -9,7 +9,7 @@ import { breakpoints } from '~/components/layout';
 
 const IndexPage = () => {
   return (
-    <Container>
+    <div>
       <Head>
         <title>Grainy Gradients playground</title>
       </Head>
@@ -38,19 +38,12 @@ const IndexPage = () => {
           <Output />
         </RightCol>
       </Row>
-    </Container>
+    </div>
   );
 };
 
 export default IndexPage;
 
-const Container = styled.div`
-  height: 100vh;
-  @media screen and (max-width: ${breakpoints.md - 1}px) {
-    height: 100%;
-  }
-`;
-
 const Scroll = styled.div`
   height: 100vh;
   overflow-y: scroll;
@@ -58,7 +51,6 @@ const Scroll = styled.div`
   background-color: #e2e2e2;
   @media screen and (max-width: ${breakpoints.md - 1}px) {
     padding: 0 ${(1 / 24) * 100}%;
-
     height: 100%;
     overflow-y: unset;
   }