Skip to content
Snippets Groups Projects
socials.tsx 2.46 KiB
Newer Older
Tojo's avatar
Tojo committed
import React, { ReactElement } from "react";
Tojo's avatar
Tojo committed
import { Content } from "@onegeo/gatsby-theme-onegeo";
Julien MARGAIL's avatar
Julien MARGAIL committed
import { Socials } from "@onegeo/gatsby-theme-onegeo";
Tojo's avatar
Tojo committed
import { graphql, Link, PageProps } from "gatsby";
Tojo's avatar
Tojo committed

Tojo's avatar
Tojo committed
type Logo = {
  id: string;
};
Tojo's avatar
Tojo committed

Tojo's avatar
Tojo committed
type Data = {
  directus: {
    partners: [id: string, name: string, logo: Logo];
  };
};

Julien MARGAIL's avatar
Julien MARGAIL committed
const Socials = ({ data }: PageProps<Data>): ReactElement => {
Tojo's avatar
Tojo committed
  const dataList = data.directus.partners;
Tojo's avatar
Tojo committed

  return (
    <Content>
      <div className="prose">
        <Link to="/doc/core">Retour</Link>

        <h1>List resaux sociaux</h1>
        <h2>Props</h2>
        <div className="mockup-code">
          <pre>
            <code>
              {`
Julien MARGAIL's avatar
Julien MARGAIL committed
              interface ISocials {
                logo?: any,
                name?: string,
                url?: string,
Tojo's avatar
Tojo committed
                layout?:string
Tojo's avatar
Tojo committed


Tojo's avatar
Tojo committed
            query {
              directus {
                partners(filter: {type: {_eq: "sociaux"}}) {
                  id
                  name
                  url
                  type
                  logo {
Tojo's avatar
Tojo committed
                    id
                  }
                }
              }
Tojo's avatar
Tojo committed
              `}
            </code>
          </pre>
        </div>

        <h2>Example</h2>
      </div>
      <h2>reseaux sociaux</h2>
      <div className="flex gap-2 m-4">
        {dataList.map((item: any) => {
          return (
            <div key={item.id}>
Julien MARGAIL's avatar
Julien MARGAIL committed
              <Socials
                name={item.name}
                url={item.url}
                logo={`${process.env.DIRECTUS_URL}assets/${item.logo.id}`}
                layout="row"
              />
            </div>
          );
        })}
Tojo's avatar
Tojo committed
      </div>

      <h2>reseaux sociaux</h2>
      <div className="flex flex-col gap-2 m-4">
        {dataList.map((item: any) => {
          return (
            <div key={item.id}>
Julien MARGAIL's avatar
Julien MARGAIL committed
              <Socials
                name={item.name}
                url={item.url}
                logo={`${process.env.DIRECTUS_URL}assets/${item.logo.id}`}
                layout="col"
              />
            </div>
          );
        })}
Tojo's avatar
Tojo committed
      </div>
      {/* <div className="flex gap-6 m-4">
Julien MARGAIL's avatar
Julien MARGAIL committed
        <Socials dataList={dataList} layout="col" />
      </div> */}
Tojo's avatar
Tojo committed
    </Content>
Julien MARGAIL's avatar
Julien MARGAIL committed
export default Socials;
Tojo's avatar
Tojo committed

Tojo's avatar
Tojo committed
export const query = graphql`
  query {
    directus {
      partners(filter: { type: { _eq: "sociaux" } }) {
        id
        name
        url
        type
        logo {
          id
        }
      }
    }
  }
`;