From 6615cd08eff5a6da2df8e809d7235319d5ece5bb Mon Sep 17 00:00:00 2001 From: Fabrizio Duroni Date: Sat, 2 Mar 2024 20:46:03 +0100 Subject: [PATCH] New article :rocket: --- .../design-system/atoms/heading5.tsx | 7 +- src/components/post-content.tsx | 8 + src/gatsby-types.d.ts | 356 ++++++++++++++++++ ...t-native-skia-svg-background-shape-text.md | 11 +- 4 files changed, 378 insertions(+), 4 deletions(-) diff --git a/src/components/design-system/atoms/heading5.tsx b/src/components/design-system/atoms/heading5.tsx index 2c6e9b858..89ae7679b 100644 --- a/src/components/design-system/atoms/heading5.tsx +++ b/src/components/design-system/atoms/heading5.tsx @@ -1,6 +1,11 @@ -import styled from "styled-components"; +import styled, { css } from "styled-components"; import { headingStyle } from "./heading-style"; +export const heading5Style = css` + font-size: ${(props) => props.theme.fontSizes[7]}; + ${headingStyle} +`; + export const Heading5 = styled.h5` font-size: ${(props) => props.theme.fontSizes[7]}; ${headingStyle} diff --git a/src/components/post-content.tsx b/src/components/post-content.tsx index 3d78db342..4dc71d763 100644 --- a/src/components/post-content.tsx +++ b/src/components/post-content.tsx @@ -5,6 +5,7 @@ import { heading4Style } from "./design-system/atoms/heading4"; import { standardLinkStyle } from "./design-system/atoms/standard-link-style"; import { syntax } from "./design-system/atoms/syntax"; import { mediaQuery } from "./design-system/utils-css/media-query"; +import { heading5Style } from "./design-system/atoms/heading5"; const PostContentContainer = styled.div` color: ${(props) => props.theme.light.primaryTextColor}; @@ -42,6 +43,13 @@ const PostContentContainer = styled.div` line-height: ${(props) => props.theme.lineHeight}; } + & h5 { + ${heading5Style}; + margin-left: 0; + margin-right: 0; + line-height: ${(props) => props.theme.lineHeight}; + } + & a { ${standardLinkStyle}; line-height: ${(props) => props.theme.lineHeight}; diff --git a/src/gatsby-types.d.ts b/src/gatsby-types.d.ts index 9103509ff..8be0c4411 100644 --- a/src/gatsby-types.d.ts +++ b/src/gatsby-types.d.ts @@ -1680,6 +1680,7 @@ type Query = { readonly allSiteFunction: SiteFunctionConnection; readonly allSitePage: SitePageConnection; readonly allSitePlugin: SitePluginConnection; + readonly allStaticImage: StaticImageConnection; readonly directory: Maybe; readonly file: Maybe; readonly imageSharp: Maybe; @@ -1689,6 +1690,7 @@ type Query = { readonly siteFunction: Maybe; readonly sitePage: Maybe; readonly sitePlugin: Maybe; + readonly staticImage: Maybe; }; @@ -1764,6 +1766,14 @@ type Query_allSitePluginArgs = { }; +type Query_allStaticImageArgs = { + filter: InputMaybe; + limit: InputMaybe; + skip: InputMaybe; + sort: InputMaybe>>; +}; + + type Query_directoryArgs = { absolutePath: InputMaybe; accessTime: InputMaybe; @@ -1954,6 +1964,46 @@ type Query_sitePluginArgs = { version: InputMaybe; }; + +type Query_staticImageArgs = { + absolutePath: InputMaybe; + accessTime: InputMaybe; + atime: InputMaybe; + atimeMs: InputMaybe; + base: InputMaybe; + birthTime: InputMaybe; + birthtime: InputMaybe; + birthtimeMs: InputMaybe; + blksize: InputMaybe; + blocks: InputMaybe; + changeTime: InputMaybe; + children: InputMaybe; + ctime: InputMaybe; + ctimeMs: InputMaybe; + dev: InputMaybe; + dir: InputMaybe; + ext: InputMaybe; + extension: InputMaybe; + id: InputMaybe; + ino: InputMaybe; + internal: InputMaybe; + mode: InputMaybe; + modifiedTime: InputMaybe; + mtime: InputMaybe; + mtimeMs: InputMaybe; + name: InputMaybe; + nlink: InputMaybe; + parent: InputMaybe; + prettySize: InputMaybe; + rdev: InputMaybe; + relativeDirectory: InputMaybe; + relativePath: InputMaybe; + root: InputMaybe; + size: InputMaybe; + sourceInstanceName: InputMaybe; + uid: InputMaybe; +}; + type Site = Node & { readonly buildTime: Maybe; readonly children: ReadonlyArray; @@ -2804,6 +2854,312 @@ type SortOrderEnum = | 'ASC' | 'DESC'; +type StaticImage = Node & { + readonly absolutePath: Maybe; + readonly accessTime: Maybe; + readonly atime: Maybe; + readonly atimeMs: Maybe; + readonly base: Maybe; + readonly birthTime: Maybe; + readonly birthtime: Maybe; + readonly birthtimeMs: Maybe; + readonly blksize: Maybe; + readonly blocks: Maybe; + readonly changeTime: Maybe; + readonly children: ReadonlyArray; + readonly ctime: Maybe; + readonly ctimeMs: Maybe; + readonly dev: Maybe; + readonly dir: Maybe; + readonly ext: Maybe; + readonly extension: Maybe; + readonly id: Scalars['ID']; + readonly ino: Maybe; + readonly internal: Internal; + readonly mode: Maybe; + readonly modifiedTime: Maybe; + readonly mtime: Maybe; + readonly mtimeMs: Maybe; + readonly name: Maybe; + readonly nlink: Maybe; + readonly parent: Maybe; + readonly prettySize: Maybe; + readonly rdev: Maybe; + readonly relativeDirectory: Maybe; + readonly relativePath: Maybe; + readonly root: Maybe; + readonly size: Maybe; + readonly sourceInstanceName: Maybe; + readonly uid: Maybe; +}; + + +type StaticImage_accessTimeArgs = { + difference: InputMaybe; + formatString: InputMaybe; + fromNow: InputMaybe; + locale: InputMaybe; +}; + + +type StaticImage_atimeArgs = { + difference: InputMaybe; + formatString: InputMaybe; + fromNow: InputMaybe; + locale: InputMaybe; +}; + + +type StaticImage_birthTimeArgs = { + difference: InputMaybe; + formatString: InputMaybe; + fromNow: InputMaybe; + locale: InputMaybe; +}; + + +type StaticImage_birthtimeArgs = { + difference: InputMaybe; + formatString: InputMaybe; + fromNow: InputMaybe; + locale: InputMaybe; +}; + + +type StaticImage_changeTimeArgs = { + difference: InputMaybe; + formatString: InputMaybe; + fromNow: InputMaybe; + locale: InputMaybe; +}; + + +type StaticImage_ctimeArgs = { + difference: InputMaybe; + formatString: InputMaybe; + fromNow: InputMaybe; + locale: InputMaybe; +}; + + +type StaticImage_modifiedTimeArgs = { + difference: InputMaybe; + formatString: InputMaybe; + fromNow: InputMaybe; + locale: InputMaybe; +}; + + +type StaticImage_mtimeArgs = { + difference: InputMaybe; + formatString: InputMaybe; + fromNow: InputMaybe; + locale: InputMaybe; +}; + +type StaticImageConnection = { + readonly distinct: ReadonlyArray; + readonly edges: ReadonlyArray; + readonly group: ReadonlyArray; + readonly max: Maybe; + readonly min: Maybe; + readonly nodes: ReadonlyArray; + readonly pageInfo: PageInfo; + readonly sum: Maybe; + readonly totalCount: Scalars['Int']; +}; + + +type StaticImageConnection_distinctArgs = { + field: StaticImageFieldSelector; +}; + + +type StaticImageConnection_groupArgs = { + field: StaticImageFieldSelector; + limit: InputMaybe; + skip: InputMaybe; +}; + + +type StaticImageConnection_maxArgs = { + field: StaticImageFieldSelector; +}; + + +type StaticImageConnection_minArgs = { + field: StaticImageFieldSelector; +}; + + +type StaticImageConnection_sumArgs = { + field: StaticImageFieldSelector; +}; + +type StaticImageEdge = { + readonly next: Maybe; + readonly node: StaticImage; + readonly previous: Maybe; +}; + +type StaticImageFieldSelector = { + readonly absolutePath: InputMaybe; + readonly accessTime: InputMaybe; + readonly atime: InputMaybe; + readonly atimeMs: InputMaybe; + readonly base: InputMaybe; + readonly birthTime: InputMaybe; + readonly birthtime: InputMaybe; + readonly birthtimeMs: InputMaybe; + readonly blksize: InputMaybe; + readonly blocks: InputMaybe; + readonly changeTime: InputMaybe; + readonly children: InputMaybe; + readonly ctime: InputMaybe; + readonly ctimeMs: InputMaybe; + readonly dev: InputMaybe; + readonly dir: InputMaybe; + readonly ext: InputMaybe; + readonly extension: InputMaybe; + readonly id: InputMaybe; + readonly ino: InputMaybe; + readonly internal: InputMaybe; + readonly mode: InputMaybe; + readonly modifiedTime: InputMaybe; + readonly mtime: InputMaybe; + readonly mtimeMs: InputMaybe; + readonly name: InputMaybe; + readonly nlink: InputMaybe; + readonly parent: InputMaybe; + readonly prettySize: InputMaybe; + readonly rdev: InputMaybe; + readonly relativeDirectory: InputMaybe; + readonly relativePath: InputMaybe; + readonly root: InputMaybe; + readonly size: InputMaybe; + readonly sourceInstanceName: InputMaybe; + readonly uid: InputMaybe; +}; + +type StaticImageFilterInput = { + readonly absolutePath: InputMaybe; + readonly accessTime: InputMaybe; + readonly atime: InputMaybe; + readonly atimeMs: InputMaybe; + readonly base: InputMaybe; + readonly birthTime: InputMaybe; + readonly birthtime: InputMaybe; + readonly birthtimeMs: InputMaybe; + readonly blksize: InputMaybe; + readonly blocks: InputMaybe; + readonly changeTime: InputMaybe; + readonly children: InputMaybe; + readonly ctime: InputMaybe; + readonly ctimeMs: InputMaybe; + readonly dev: InputMaybe; + readonly dir: InputMaybe; + readonly ext: InputMaybe; + readonly extension: InputMaybe; + readonly id: InputMaybe; + readonly ino: InputMaybe; + readonly internal: InputMaybe; + readonly mode: InputMaybe; + readonly modifiedTime: InputMaybe; + readonly mtime: InputMaybe; + readonly mtimeMs: InputMaybe; + readonly name: InputMaybe; + readonly nlink: InputMaybe; + readonly parent: InputMaybe; + readonly prettySize: InputMaybe; + readonly rdev: InputMaybe; + readonly relativeDirectory: InputMaybe; + readonly relativePath: InputMaybe; + readonly root: InputMaybe; + readonly size: InputMaybe; + readonly sourceInstanceName: InputMaybe; + readonly uid: InputMaybe; +}; + +type StaticImageGroupConnection = { + readonly distinct: ReadonlyArray; + readonly edges: ReadonlyArray; + readonly field: Scalars['String']; + readonly fieldValue: Maybe; + readonly group: ReadonlyArray; + readonly max: Maybe; + readonly min: Maybe; + readonly nodes: ReadonlyArray; + readonly pageInfo: PageInfo; + readonly sum: Maybe; + readonly totalCount: Scalars['Int']; +}; + + +type StaticImageGroupConnection_distinctArgs = { + field: StaticImageFieldSelector; +}; + + +type StaticImageGroupConnection_groupArgs = { + field: StaticImageFieldSelector; + limit: InputMaybe; + skip: InputMaybe; +}; + + +type StaticImageGroupConnection_maxArgs = { + field: StaticImageFieldSelector; +}; + + +type StaticImageGroupConnection_minArgs = { + field: StaticImageFieldSelector; +}; + + +type StaticImageGroupConnection_sumArgs = { + field: StaticImageFieldSelector; +}; + +type StaticImageSortInput = { + readonly absolutePath: InputMaybe; + readonly accessTime: InputMaybe; + readonly atime: InputMaybe; + readonly atimeMs: InputMaybe; + readonly base: InputMaybe; + readonly birthTime: InputMaybe; + readonly birthtime: InputMaybe; + readonly birthtimeMs: InputMaybe; + readonly blksize: InputMaybe; + readonly blocks: InputMaybe; + readonly changeTime: InputMaybe; + readonly children: InputMaybe; + readonly ctime: InputMaybe; + readonly ctimeMs: InputMaybe; + readonly dev: InputMaybe; + readonly dir: InputMaybe; + readonly ext: InputMaybe; + readonly extension: InputMaybe; + readonly id: InputMaybe; + readonly ino: InputMaybe; + readonly internal: InputMaybe; + readonly mode: InputMaybe; + readonly modifiedTime: InputMaybe; + readonly mtime: InputMaybe; + readonly mtimeMs: InputMaybe; + readonly name: InputMaybe; + readonly nlink: InputMaybe; + readonly parent: InputMaybe; + readonly prettySize: InputMaybe; + readonly rdev: InputMaybe; + readonly relativeDirectory: InputMaybe; + readonly relativePath: InputMaybe; + readonly root: InputMaybe; + readonly size: InputMaybe; + readonly sourceInstanceName: InputMaybe; + readonly uid: InputMaybe; +}; + type StringQueryOperatorInput = { readonly eq: InputMaybe; readonly glob: InputMaybe; diff --git a/src/posts/2024-03-10-react-native-skia-svg-background-shape-text.md b/src/posts/2024-03-10-react-native-skia-svg-background-shape-text.md index de1332471..e4172dc14 100644 --- a/src/posts/2024-03-10-react-native-skia-svg-background-shape-text.md +++ b/src/posts/2024-03-10-react-native-skia-svg-background-shape-text.md @@ -3,7 +3,7 @@ title: "React Native is Native: drawing customized background shapes with React description: "A lot of mobile developer often complains that React Native is not Native, because it is missing some feature. This is absolutely not true! In this blog post I will show you how I create a component with a custom background shape, similar to the one I did for a native component ome time ago" -date: 2024-03-10 +date: 2024-03-02 image: ../images/posts/daily-deals-featured.jpg tags: [react native, swift, ios, apple, android, java, mobile application development, javascript, typescript] comments: true @@ -44,6 +44,8 @@ framework above, to evaluate their usage complexity. ![The component on both platforms: iOS and Android](../images/posts/daily-deals-featured.jpg) +`youtube: https://www.youtube.com/watch?v=96wofMjkyKc` + #### Implementation The implementation of the components in the image and video above is composed of two parts: @@ -335,8 +337,8 @@ This means that `getPolygonFeatures` will always return a polygon shape coherent The `PolygonFeatures` are composed by: * the position of the four vertices (it is always a quadrilateral shape, but as a challenge you can try to abstract - this part :smirk:) -* the size of the background. + this part, if you want to have some fun :smirk:) +* the background size ```tsx import React, {FC, ReactElement, useEffect, useState} from 'react'; @@ -524,6 +526,9 @@ export const DailyDealsShapeSkia: FC = ({ }; ``` +As you can see from the implementation above, the more complicated part is outside Skia/SVG. They are simple +components focused on the drawing part. + #### Conclusion You can find the full implementation of what I described above in this [github repo](https://github.com/chicio/React-Native-Background-Shape-Skia-Svg).