<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: ma2web</title>
    <description>The latest articles on DEV Community by ma2web (@ma2web).</description>
    <link>https://dev.to/ma2web</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F271217%2Ff59eaac5-8b5b-4c60-b416-ce4df30726cc.jpeg</url>
      <title>DEV Community: ma2web</title>
      <link>https://dev.to/ma2web</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ma2web"/>
    <language>en</language>
    <item>
      <title>Add more variant to Material-UI Typography</title>
      <dc:creator>ma2web</dc:creator>
      <pubDate>Wed, 14 Jul 2021 16:24:28 +0000</pubDate>
      <link>https://dev.to/ma2web/add-more-variant-to-material-ui-typography-1nl9</link>
      <guid>https://dev.to/ma2web/add-more-variant-to-material-ui-typography-1nl9</guid>
      <description>&lt;p&gt;Hey there,&lt;/p&gt;

&lt;p&gt;You know that Material-UI Typography component has variant props that include 15 default types such as: &lt;code&gt;h1 ~ h6&lt;/code&gt;, &lt;code&gt;subtitle1&lt;/code&gt;, &lt;code&gt;body1&lt;/code&gt;, and so on. you can see options here &lt;a href="https://material-ui.com/api/typography/"&gt;https://material-ui.com/api/typography/&lt;/a&gt;&lt;br&gt;
now, if you want to add some more to your Typography component and have more design for it you must create a custom typography component like below.&lt;/p&gt;

&lt;p&gt;this is &lt;code&gt;MyTypography.tsx&lt;/code&gt; that is in my components directory.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { TypographyProps, Typography } from '@material-ui/core'
import classNames from 'classnames'
import React, { ElementType, FC } from 'react'
import useMyTypographyStyle from './MyTypography.styles'

interface IMyTypography extends Omit&amp;lt;TypographyProps, 'variant'&amp;gt; {
  variant:
  | TypographyProps['variant']
  | 'h2Bold'
  | 'subtitle1Bold'
  component?: ElementType
}
const MyTypography: FC&amp;lt;IMyTypography&amp;gt; = (props) =&amp;gt; {
  const classes = useMyTypographyStyle()
  const isCustom = Object.keys(classes).indexOf(props.variant) &amp;gt; -1
  return (
    &amp;lt;Typography
      {...props}
      variant={isCustom ? undefined : (props.variant as any)}
      className={
        isCustom
          ? classNames(classes[props.variant], props.className)
          : props.className
      }
    &amp;gt;
      {props.children}
    &amp;lt;/Typography&amp;gt;
  )
}

export default MyTypography
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this case we made a component that it variant get undefined or default Material-UI Typography variant based on &lt;code&gt;isCustom&lt;/code&gt; value and this value is the props when we pass to &lt;code&gt;MyTypography&lt;/code&gt; component.&lt;br&gt;
Also you must have a style file for add your design to your custom variants.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { makeMyStyles } from 'theme'

const useMyTypographyStyle = makeMyStyles(
  ({ typography }) =&amp;gt; ({
    h2Bold: { ...typography.h2, fontWeight: 700 },
    subtitle1Bold: { ...typography.subtitle1, fontWeight: 700 },
  }),
  { name: 'myTypography' },
)

export default useMyTypographyStyle
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Thats it. we done it. now you have 17 values for your variant props and when you want to use Typography component you must use it like this&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;MyTypography variant='h2Bold'&amp;gt;heading 2 with custom styles&amp;lt;/MyTypography&amp;gt;
&amp;lt;MyTypography variant='subtitle1Bold'&amp;gt;subtutle 1 with custom styles&amp;lt;/MyTypography&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
    <item>
      <title>get number of product in each category with mongodb aggregate</title>
      <dc:creator>ma2web</dc:creator>
      <pubDate>Fri, 25 Jun 2021 08:18:16 +0000</pubDate>
      <link>https://dev.to/ma2web/get-number-of-product-in-each-category-with-mongodb-aggregate-1jc3</link>
      <guid>https://dev.to/ma2web/get-number-of-product-in-each-category-with-mongodb-aggregate-1jc3</guid>
      <description>&lt;p&gt;In one project, the Android developer asked me to give me an API that can show product categories with the number of products in each category; the best way to create this API in MongoDB is to use the 'aggregate' operator.&lt;br&gt;
This was my category schema.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const mongoose = require("mongoose");
const { s, rs, n, ref } = require("../utils/mongo");

var schema = new mongoose.Schema(
  {
    user: ref("user"),
    name: { ...rs, unique: true },
    description: s,
    image: s,
    view: {
      ...n,
      default: 0,
    },
  },
  { timestamps: true }
);

module.exports = mongoose.model("category", schema);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and you can see my controller in below&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;module.exports = {
  getAll: async (req, res) =&amp;gt; {
    await Category.aggregate([
        {
          $lookup: {
            from: "products",
            localField: "_id",
            foreignField: "categories",
            as: "products",
          },
        },
        {
          $project: {
            _id: 1,
            name: 1,
            products: { $size: "$products" },
            description: 1,
            view: 1,
            createdAt: 1,
            updatedAt: 1,
          },
        },
      ]).exec(function (err, result) {
        if (err) throw err;
        res.send(result);
      });
  },
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and this is postman result&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flsqz60jwctplm2lqbmcn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flsqz60jwctplm2lqbmcn.png" alt="postman result" width="800" height="452"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Animated SVG - GSAP</title>
      <dc:creator>ma2web</dc:creator>
      <pubDate>Thu, 29 Oct 2020 15:44:17 +0000</pubDate>
      <link>https://dev.to/ma2web/animated-svg-gsap-1jii</link>
      <guid>https://dev.to/ma2web/animated-svg-gsap-1jii</guid>
      <description>&lt;p&gt;I made an animated landing page with HTML, CSS and GSAP-(JavaScript animation library from GreenSock)&lt;/p&gt;

&lt;p&gt;Codes, SVG file, Fonts, Adobe XD file and Affinity designer file are here:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://gitlab.com/ma2web/svg-animated-with-gsap"&gt;https://gitlab.com/ma2web/svg-animated-with-gsap&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;hope be useful for you&lt;/p&gt;

</description>
    </item>
    <item>
      <title>React JS - Material UI Dashboard</title>
      <dc:creator>ma2web</dc:creator>
      <pubDate>Thu, 08 Oct 2020 16:07:24 +0000</pubDate>
      <link>https://dev.to/ma2web/my-react-dashboard-524a</link>
      <guid>https://dev.to/ma2web/my-react-dashboard-524a</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fod24j4r9i6aymhx52ge6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fod24j4r9i6aymhx52ge6.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;React admin panel created with React, Redux and using material-ui framework&lt;/p&gt;

&lt;p&gt;login without user / pass&lt;/p&gt;

&lt;p&gt;Codes: &lt;a href="https://gitlab.com/ma2web/material-ui-blue-sky" rel="noopener noreferrer"&gt;https://gitlab.com/ma2web/material-ui-blue-sky&lt;/a&gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
