<commit_before>import PropTypes from "prop-types";
import React, { useCallback, useEffect, useState } from "react";
import styled from "styled-components";

import style from "@agir/front/genericComponents/_variables.scss";
import illustration from "@agir/groups/groupPage/images/empty-messages-bg.svg";

import { RawFeatherIcon } from "@agir/front/genericComponents/FeatherIcon";

const StyledAnnouncement = styled.div`
  width: 100%;
  display: flex;
  padding: 1rem 1.75rem;
  flex-flow: row nowrap;
  align-items: center;
  justify-content: space-between;
  background-color: ${style.secondary100};
  position: relative;

  @media (max-width: ${style.collapse}px) {
    padding: 1rem;
    padding-right: 3rem;
  }

  & > * {
    flex: 0 0 auto;
  }

  div {
    width: 102px;
    height: 98px;
    background-image: url(${illustration});
    background-repeat: no-repeat;
    background-size: contain;
    background-position: center left;
    margin-right: 1.5rem;

    @media (max-width: ${style.collapse}px) {
      display: none;
    }
  }

  p {
    flex: 1 1 auto;
    margin: 0;
    display: flex;
    flex-flow: column nowrap;
    justify-content: center;

    & > * {
      display: block;
      margin: 0;
      line-height: 1.6;
    }

    span {
      font-weight: 400;
    }

    strong {
      font-weight: 600;
    }

    a {
      text-decoration: underline;
    }
  }

  button {
    display: inline-flex;
    background-color: transparent;
    border: none;
    outline: none;
    cursor: pointer;
    padding: 0;
    margin: 0;
    position: absolute;
    top: 0.875rem;
    right: 1rem;

    @media (max-width: ${style.collapse}px) {
      right: 0.875rem;
    }
  }
`;

const DiscussionAnnouncement = ({ isActive, onClose, link }) => {
  const [shouldShow, setShouldShow] = useState(isActive);

  const close = useCallback(() => {
    setShouldShow(false);
    onClose && onClose();
  }, [onClose]);

  useEffect(() => {
    setShouldShow(isActive);
  }, [isActive]);

  return shouldShow ? (
    <StyledAnnouncement>
      <div aria-hidden="true" />
      <p>
        <br />
        <strong>
          Nouveau&nbsp;: discutez de vos prochaines actions ici&nbsp;!
        </strong>
        <br />
        <span>
          Vos animateur·ices publieront des messages auxquels vous pourrez
          répondre sur cette page.{" "}
          {link ? (
            <a href={link} target="_blank" rel="noopener noreferrer">
              En savoir plus
            </a>
          ) : null}
        </span>
      </p>
      <button onClick={close} aria-label="Fermer ce message">
        <RawFeatherIcon name="x" color={style.black1000} />
      </button>
    </StyledAnnouncement>
  ) : null;
};
DiscussionAnnouncement.propTypes = {
  isActive: PropTypes.bool,<commit_msg>fix: DiscussionAnnouncement strange margins<commit_after>import PropTypes from "prop-types";
import React, { useCallback, useEffect, useState } from "react";
import styled from "styled-components";

import style from "@agir/front/genericComponents/_variables.scss";
import illustration from "@agir/groups/groupPage/images/empty-messages-bg.svg";

import { RawFeatherIcon } from "@agir/front/genericComponents/FeatherIcon";

const StyledAnnouncement = styled.div`
  width: 100%;
  display: flex;
  padding: 1rem 1.75rem;
  flex-flow: row nowrap;
  align-items: center;
  justify-content: space-between;
  background-color: ${style.secondary100};
  position: relative;

  @media (max-width: ${style.collapse}px) {
    padding: 1rem;
    padding-right: 3rem;
  }

  & > * {
    flex: 0 0 auto;
  }

  div {
    width: 102px;
    height: 98px;
    background-image: url(${illustration});
    background-repeat: no-repeat;
    background-size: contain;
    background-position: center left;
    margin-right: 1.5rem;

    @media (max-width: ${style.collapse}px) {
      display: none;
    }
  }

  p {
    flex: 1 1 auto;
    margin: 0;
    display: flex;
    flex-flow: column nowrap;
    justify-content: center;

    & > * {
      display: block;
      margin: 0;
      line-height: 1.6;
    }

    span {
      font-weight: 400;
    }

    strong {
      font-weight: 600;
    }

    a {
      text-decoration: underline;
    }
  }

  button {
    display: inline-flex;
    background-color: transparent;
    border: none;
    outline: none;
    cursor: pointer;
    padding: 0;
    margin: 0;
    position: absolute;
    top: 0.875rem;
    right: 1rem;

    @media (max-width: ${style.collapse}px) {
      right: 0.875rem;
    }
  }
`;

const DiscussionAnnouncement = ({ isActive, onClose, link }) => {
  const [shouldShow, setShouldShow] = useState(isActive);

  const close = useCallback(() => {
    setShouldShow(false);
    onClose && onClose();
  }, [onClose]);

  useEffect(() => {
    setShouldShow(isActive);
  }, [isActive]);

  return shouldShow ? (
    <StyledAnnouncement>
      <div aria-hidden="true" />
      <p>
        <strong>
          Nouveau&nbsp;: discutez de vos prochaines actions ici&nbsp;!
        </strong>
        <span>
          Vos animateur·ices publieront des messages auxquels vous pourrez
          répondre sur cette page.{" "}
          {link ? (
            <a href={link} target="_blank" rel="noopener noreferrer">
              En savoir plus
            </a>
          ) : null}
        </span>
      </p>
      <button onClick={close} aria-label="Fermer ce message">
        <RawFeatherIcon name="x" color={style.black1000} />
      </button>
    </StyledAnnouncement>
  ) : null;
};
DiscussionAnnouncement.propTypes = {
  isActive: PropTypes.bool,
{'fraction_non_alphanumeric': 0.1342293906810036, 'fraction_numerical': 0.017204301075268817, 'mean_word_length': 2.5322784810126584, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 43, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '978041', 'n_tokens_mistral': 1944, 'n_tokens_neox': 1823, 'n_words': 422}