Skip to content

Commit

Permalink
Apply text field style update (#57)
Browse files Browse the repository at this point in the history
* Coding standard

* WIP - Issue #7: Text form items

* WIP - Issue #7: Style update for date form items

* WIP - Issue #7: Template update for date form item states

* WIP - Issue #7: Minor workaround for iOS date and time inputs

* WIP - Issue #7: Increase font size to 16px/1.5

* Issue #7: Convert form-item to BEM

* Issue #7: Fixing PR change requests

* Issue #7: Fixup for theme rename and component-based text input theming

* Issue #7: Fixup for image-widget

* Issue #7: Fix for PR review

* Issue #7 - Standarize hook comment

* Issue #7: CS fix for fieldset preprocess
  • Loading branch information
zolhorvath authored and lauriii committed Dec 12, 2018
1 parent dc68d25 commit 5718c8a
Show file tree
Hide file tree
Showing 19 changed files with 743 additions and 297 deletions.
51 changes: 40 additions & 11 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,17 @@

## Our Pledge

In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, gender identity and expression, level of
experience, nationality, personal appearance, race, religion, or sexual identity
and orientation.

## Our Standards

Examples of behavior that contributes to creating a positive environment include:
Examples of behavior that contributes to creating a positive environment
include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
Expand All @@ -17,31 +23,54 @@ Examples of behavior that contributes to creating a positive environment include

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or advances
* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting

## Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
Project maintainers have the right and responsibility to remove, edit, or reject
comments, commits, code, wiki edits, issues, and other contributions that are
not aligned to this Code of Conduct, or to ban temporarily or permanently any
contributor for other behaviors that they deem inappropriate, threatening,
offensive, or harmful.

## Scope

This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team (@ckrina, @justafish or @drpal) on Drupal Slack. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team (@ckrina, @justafish or @drpal) on
Drupal Slack. The project team will review and investigate all complaints, and
will respond in a way that it deems appropriate to the circumstances. The
project team is obligated to maintain confidentiality with regard to the
reporter of an incident. Further details of specific enforcement policies may be
posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 1.4, available at [http://contributor-covenant.org/version/1/4][version]

[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Claro Drupal admin theme

## Pre-requisites
Before starting, ensure that you are using at least the latest LTS release of Node.js, once Node.js has been installed, we recommend to install yarn
Before starting, ensure that you are using at least the latest LTS release of
Node.js, once Node.js has been installed, we recommend to install yarn
```
npm i -g yarn
```
Expand All @@ -12,7 +13,8 @@ yarn install
```

## Working on Javascript
When developing JavaScript locally you can use the watcher to make changes and have them compiled as you save as well as generate source maps.
When developing JavaScript locally you can use the watcher to make changes and
have them compiled as you save as well as generate source maps.

```
yarn run watch:js
Expand Down
6 changes: 5 additions & 1 deletion claro.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ base theme: classy
description: 'The default administration theme for Drupal 8 was designed with clean lines, simple blocks, and sans-serif font to emphasize the tools and tasks at hand.'
alt text: 'Default administration theme for Drupal 8 with simple blocks and clean lines.'
package: Core
version: VERSION
# version: VERSION
core: 8.x
libraries:
- claro/global-styling
Expand Down Expand Up @@ -46,6 +46,7 @@ libraries-override:
css:
component:
css/components/details.css: false
css/components/form.css: false

libraries-extend:
core/ckeditor:
Expand All @@ -56,6 +57,9 @@ libraries-extend:
- claro/claro.jquery.ui
tour/tour-styling:
- claro/tour-styling
classy/image-widget:
- claro/image-widget

quickedit_stylesheets:
- css/dist/components/quickedit.css
regions:
Expand Down
8 changes: 8 additions & 0 deletions claro.libraries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ global-styling:
css/dist/components/entity-meta.css: {}
css/dist/components/field-ui.css: {}
css/dist/components/form.css: {}
css/dist/components/form--select.css: {}
css/dist/components/form--text.css: {}
css/dist/components/help.css: {}
css/dist/components/menus-and-lists.css: {}
css/dist/components/modules-page.css: {}
Expand Down Expand Up @@ -133,3 +135,9 @@ media-form:
css/dist/components/media.css: {}
dependencies:
- media/form

image-widget:
version: VERSION
css:
component:
css/dist/layout/image-widget.css: {}
87 changes: 87 additions & 0 deletions claro.theme
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* Functions to support theming in the Claro theme.
*/

use Drupal\Component\Utility\Html;
use Drupal\Core\Form\FormStateInterface;
use Drupal\media\MediaForm;

Expand Down Expand Up @@ -179,3 +180,89 @@ function claro_form_media_form_alter(&$form, FormStateInterface $form_state) {
$form['#attached']['library'][] = 'claro/media-form';
}
}

/**
* Implements hook_preprocess_form_element().
*/
function claro_preprocess_form_element(&$variables) {
if (!empty($variables['element']['#errors'])) {
$variables['label']['#attributes']['class'][] = 'has-error';
}

if ($variables['disabled']) {
$variables['label']['#attributes']['class'][] = 'is-disabled';

if (!empty($variables['description']['attributes'])) {
$variables['description']['attributes']->addClass('is-disabled');
}
}
}

/**
* Implements template_preprocess_HOOK() for input.
*/
function claro_preprocess_input(&$variables) {
$type_api = $variables['element']['#type'];
$type_html = $variables['attributes']['type'];
$text_types_html = [
'text',
'email',
'tel',
'number',
'search',
'password',
'date',
'time',
'file',
'color',
'datetime-local',
'url',
'month',
'week',
];

if (in_array($type_html, $text_types_html)) {
$variables['attributes']['class'][] = 'form-element';
$variables['attributes']['class'][] = Html::getClass('form-element--type-' . $type_html);
$variables['attributes']['class'][] = Html::getClass('form-element--api-' . $type_api);
}
}

/**
* Implements template_preprocess_HOOK() for textarea.
*/
function claro_preprocess_textarea(&$variables) {
$variables['attributes']['class'][] = 'form-element';
$variables['attributes']['class'][] = 'form-element--type-textarea';
$variables['attributes']['class'][] = 'form-element--api-textarea';
}

/**
* Implements template_preprocess_HOOK() for datetime_wrapper.
*/
function claro_preprocess_datetime_wrapper(&$variables) {
if (!empty($variables['element']['#errors'])) {
$variables['title_attributes']['class'][] = 'has-error';
}

if (!empty($variables['element']['#disabled'])) {
$variables['title_attributes']['class'][] = 'is-disabled';

if (!empty($variables['description_attributes'])) {
$variables['description_attributes']->addClass('is-disabled');
}
}
}

/**
* Implements template_preprocess_HOOK() for fieldset.
*/
function claro_preprocess_fieldset(&$variables) {
if (!empty($variables['element']['#disabled'])) {
$variables['legend_span']['attributes']->addClass('is-disabled');

if (!empty($variables['description']) && !empty($variables['description']['attributes'])) {
$variables['description']['attributes']->addClass('is-disabled');
}
}
}
3 changes: 1 addition & 2 deletions css/src/base/elements.css
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ hr {
background: #ccc;
}

summary,
.fieldgroup:not(.form-composite) > legend {
summary {
font-weight: bold;
text-transform: uppercase;
}
Expand Down
11 changes: 11 additions & 0 deletions css/src/components/container-inline.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,14 @@
.container-inline label {
display: inline-block;
}

.form-items-inline {
margin-top: -0.125em; /* 2px */
margin-bottom: -0.125em;
}

.form-items-inline > .form-item {
display: inline-block;
margin-top: 0.125em;
margin-bottom: 0.125em;
}
84 changes: 84 additions & 0 deletions css/src/components/form--select.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/**
* @file
* Select input elements.
*/

/**
* Limits extra long instances of select elements to the max width allowed
* to avoid breaking layouts.
*/
select {
max-width: 100%;
}

.form-disabled select.form-select {
border-color: #d4d4d4;
background-color: hsla(0, 0%, 0%, 0.08);
box-shadow: none;
}

.form-item select.error {
border-width: 1px;
border-color: #e62600;
background-color: hsla(15, 75%, 97%, 1);
box-shadow: inset 0 5px 5px -5px #b8b8b8;
color: #a51b00;
}

.form-item select.error:focus {
border-color: #e62600;
outline: 0;
box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.05), 0 0 8px 1px #e62600;
background-color: #fcf4f2;
}

/* Exceptions */
#diff-inline-form select,
div.filter-options select {
padding: 0;
}

/**
* Select elements - Webkit only
*/
@media screen and (-webkit-min-device-pixel-ratio: 0) {
select {
cursor: pointer;
-webkit-appearance: none;
padding: 1px 1.571em 1px 0.5em; /* LTR */
border: 1px solid #a6a6a6;
border-radius: 0.143em;
background:
url(../../../../misc/icons/333333/caret-down.svg) no-repeat 99% 63%,
-webkit-linear-gradient(top, #f6f6f3, #e7e7df); /* LTR */

text-shadow: 0 1px hsla(0, 0%, 100%, 0.6);
font-size: 0.875rem;
-webkit-transition: all 0.1s;
transition: all 0.1s;
-webkit-font-smoothing: antialiased;
}
[dir="rtl"] select {
padding: 1px 0.714em 1px 1.571em;
background-position: 1% 63%, 0 0;
}
select:focus,
select:hover {
background-image:
url(../../../../misc/icons/333333/caret-down.svg),
-webkit-linear-gradient(top, #fcfcfa, #e9e9dd);
color: #1a1a1a;
}
select:hover {
box-shadow: 0 1px 2px hsla(0, 0%, 0%, 0.125);
}
}

/**
* Improve form element usability on narrow devices.
*/
@media screen and (max-width: 600px) {
select {
width: 100%;
}
}
Loading

0 comments on commit 5718c8a

Please sign in to comment.