diff --git a/css/message-teaser.css b/css/message-teaser.css new file mode 100644 index 0000000..3318d44 --- /dev/null +++ b/css/message-teaser.css @@ -0,0 +1,51 @@ +/** + * @file + * Stylesheet for inmail. + */ +.inmail--view-mode-teaser { + margin: 10px; +} +.inmail-message--body, +.inmail-message--header { + display: flex; +} +.inmail-message--header-from, +.inmail-message--header-to { + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} +.inmail-message--header-cc, +.inmail-message--body-plain { + display: inline-block; +} +.inmail-message--header-from { + margin: 0 1em 0 0; +} +.inmail-message--header-to { + margin: 0 1em 0 1em; +} +.inmail-message--header-cc { + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + flex-basis: auto; + margin-left: 1em; + color: #777; +} +.inmail-message--body-subject { + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + flex-basis: auto; + margin-right: 1em; +} +.inmail-message--body-plain { + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + flex-basis: 50%; + margin-left: 1em; + color: #777; + font-size: 88%; +} diff --git a/css/message.css b/css/message.css index d905d25..08ddcfe 100644 --- a/css/message.css +++ b/css/message.css @@ -2,30 +2,26 @@ * @file * Stylesheet for inmail. */ +.inmail--view-mode-full { + margin: 10px; +} .inmail-message--header header { display: -webkit-flex; display: flex; flex-wrap: wrap; } - -.inmail-message--header-from, -.inmail-message--header-to, -.inmail-message--header-subject, -.inmail-message--header-received-date { - margin: 10px; -} - -.inmail-message--header-label { +.inmail-message--header-label, +.inmail-message--footer-label { font-weight: 700; + display: inline-block; + width: 100px; } - -.inmail-message--header-all-body{ - font-family: monospace; - white-space: pre; +.inmail-message--header, +.inmail-message--body, +.inmail-message--footer { + margin: 10px; } - -.inmail--view-mode-teaser .inmail-message--body-plain { - white-space: nowrap; - overflow: hidden; - text-overflow: ellipsis; +.inmail-message--header-all { + display: none; } + diff --git a/inmail.libraries.yml b/inmail.libraries.yml index bc382ea..2d755d9 100644 --- a/inmail.libraries.yml +++ b/inmail.libraries.yml @@ -3,3 +3,9 @@ message: css: theme: css/message.css: {} + +message_teaser: + version: 1.x + css: + theme: + css/message-teaser.css: {} diff --git a/templates/inmail-message.html.twig b/templates/inmail-message.html.twig index c316276..861a249 100644 --- a/templates/inmail-message.html.twig +++ b/templates/inmail-message.html.twig @@ -19,71 +19,87 @@ */ #} -{{ attach_library('inmail/message') }} - {% if view_mode == 'teaser' %} + {{ attach_library('inmail/message_teaser') }} + - {{ message.from }} - {% if message.getTo is not empty %} - {{ message.getTo | join(', ') }} - {% endif %} - {% if message.getCc is not empty %} - {{ message.getCc | join(', ') }} - {% endif %} - {{ message.subject }} - {{ message.getReceivedDate() }} + + {{ message.from }} + > + {% if message.getTo is not empty %} + {{ message.getTo | join(', ') }} + {% endif %} + {% if message.getCc is not empty %} + | + {{ message.getCc | join(', ') }} + {% endif %} + - {{ message.getPlainText() | slice(0, 1000) }} + + {% if message.subject is not empty %} + {{ message.subject }} + | + {% endif %} + {{ message.getPlainText() | slice(0, 1000) }} + {% endif %} {% if view_mode == 'full' %} + {{ attach_library('inmail/message') }} + - - From - {{ message.from }} - - {% if message.getTo is not empty %} - - To - {{ message.getTo | join(', ') }} + + + From + {{ message.from }} - {% endif %} - {% if message.getCc is not empty %} - - CC - {{ message.getCc | join(', ') }} + {% if message.getTo is not empty %} + + To + {{ message.getTo | join(', ') }} + + {% endif %} + {% if message.getCc is not empty %} + + CC + {{ message.getCc | join(', ') }} + + {% endif %} + + Received + {{ message.getReceivedDate() }} + + + Subject + {{ message.subject }} + + + All Headers + {{ message.header.toString() }} - {% endif %} - - Received - {{ message.getReceivedDate() }} - - - Subject - {{ message.subject }} - - - All Headers - {{ message.header.toString() }} {# Use getPlainText() after https://www.drupal.org/node/2405069. #} {{ message.getDecodedBody() }} {% if attachments %} {% endif %}