Skip to content

Commit 83df56c

Browse files
committed
DOC-3156: Clarify skin creation instructions in UI customization documentation.
1 parent e5ecdb3 commit 83df56c

File tree

1 file changed

+118
-68
lines changed

1 file changed

+118
-68
lines changed
Lines changed: 118 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,91 +1,110 @@
1-
= Create a skin for TinyMCE
2-
:description: Introducing skin creation, less and icon modification.
3-
:description_short: Introducing skin creation.
4-
:keywords: create creator skin icon
5-
:title_nav: Create a skin
1+
= Create a Skin for {productname}
2+
:navtitle: Create a Skin
3+
:description_short: Introduction to skin creation.
4+
:description: Learn how to create a custom skin, modify Less variables, and update icons for {productname}.
5+
:keywords: create, skin, customization, icon, Less
66

7-
This section provides information on how to manually create a new skin to customize the appearance of {productname} {productmajorversion}.
7+
This guide explains how to manually create a new skin to customize the appearance of {productname} {productmajorversion}.
88

99
== Prerequisites
1010

11-
This guide assumes:
11+
Before beginning, ensure that:
1212

13-
* Familiarity with the command line and running simple commands.
14-
* https://nodejs.org/en/[Node.js], https://yarnpkg.com/en/[Yarn] and https://gulpjs.com[Gulp] are already installed.
15-
* Basic understanding of http://lesscss.org[Less], the CSS preprocessor we use to build the skins. More specifically, http://lesscss.org/features/#variables-feature[read the section about variables].
13+
* Familiarity with the command line and basic commands is established.
14+
* link:https://nodejs.org/en/[Node.js] and link:https://yarnpkg.com/en/[Yarn] are already installed.
15+
* A basic understanding of link:http://lesscss.org[Less], the CSS preprocessor used to build skins, is required. Specifically, review the link:http://lesscss.org/features/#variables-feature[section on variables].
1616

1717
== Preparation
1818

19-
The CSS that goes with a theme is called a skin. The default skin for {productname} {productmajorversion} is named Oxide and is written in http://lesscss.org[Less], a popular CSS preprocessor. With Oxide we introduced a concept we call the *Style API*. This API consists of around 300 variables which you use to modify the appearance of {productname}. You never touch the underlying CSS. The benefit of this approach is that improvements we make to the CSS and HTML won't break your custom skin. This also means that if things don't work as expected, we can provide support and bug fixes, something that was virtually impossible before.
19+
The CSS associated with a theme is called a skin. The default skin for {productname} {productmajorversion} is **Oxide**, written in link:http://lesscss.org[Less]. Oxide introduces the *Style API*, which consists of approximately 300 variables that allow customization of {productname} without modifying the underlying CSS. This approach ensures compatibility with future updates and provides continued support for bug fixes.
2020

21-
IMPORTANT: We do not recommend modifying or overriding CSS rules directly.
21+
[IMPORTANT]
22+
{companyname} recommends not modifying or overriding CSS rules directly.
2223

23-
To set up the skin development environment, begin with the following steps:
24+
Follow these steps to set up the skin development environment:
2425

25-
. Download (or `git clone`) the https://github.com/tinymce/tinymce[{productname} source code].
26-
. Open the terminal and navigate to the folder you just downloaded.
27-
. Install dependencies with the command:
26+
. Download (or `+git clone+`) the link:https://github.com/tinymce/tinymce[{productname} source code].
27+
. Open a terminal and navigate to the folder you just downloaded.
28+
. Install dependencies and build the project using the following commands:
2829
+
29-
[source, sh]
30+
[source,sh]
3031
----
31-
yarn install
32+
yarn && yarn dev && yarn build
3233
----
33-
34-
. Launch the web server to preview the skins using the command:
34+
. Start the development server to preview skins:
3535
+
36-
[source, sh]
36+
[source,sh]
3737
----
3838
yarn oxide-start
3939
----
40+
. Once the server starts, open a browser and navigate to the displayed URL, typically `+http://localhost:3000+`.
4041

41-
You should now be able to open a web browser and point it to the url displayed in the terminal, usually `+http://localhost:3000+`.
42+
The development environment is now setup and should look similar to the following:
4243

43-
The development environment is set up and ready to work.
44+
image::SDK-for-silver.png[{productname} skin SDK for Silver theme]
4445

45-
image::SDKforsilver.png[{productname} skin SDK for Silver theme]
46+
[NOTE]
47+
If required to modify the skin without launching a web server, run **`+yarn oxide-build+`** instead of **`+yarn oxide-start+`**.
4648

47-
If you just need to build the skins without launching a web server, run:
49+
== Creating or Editing a Skin
4850

49-
[source, sh]
50-
----
51-
yarn oxide-build
52-
----
51+
Ensure completion of the preparation steps before proceeding.
5352

54-
== Making or editing a skin
53+
=== Directory Structure
5554

56-
Make sure you have performed the preparation steps above.
55+
Navigate to `+modules/oxide/src/less/skins/+`. This folder contains:
5756

58-
=== Overview
57+
. `+/ui+`: Contains editor UI skins. The main file here is `+skin.less+`.
58+
. `+/content+`: Contains skins for the content inside the editor.
5959

60-
Navigate to `modules/oxide/src/less/skins/`. There are two folders in this location:
61-
* `/ui` - which is the skins for the editor. The important file here is `skin.less`.
62-
* `/content` - which is the skins for the content within the editor.
60+
The `+modules/oxide/src/less/theme/+` folder contains Less files defining global styles. Most files list available variables at the top, such as colors, margins, and fonts. Variables are prefixed with `@` (e.g., `@background-color`).
6361

64-
The folder `modules/oxide/src/less/theme/` contains the Less files. At the top of most files you'll find the available variables that defines the default colors, margins, fonts etc (variables are the strings that starts with an at-character, for example `@background-color`). _Do not edit these files_, instead use them as a reference when creating your skin. We recommend starting with the two files containing global variables: `modules/oxide/src/less/theme/globals/global-variables.less` and the toolbar buttons: `modules/oxide/src/less/theme/components/toolbar-button/toolbar-button.less`.
62+
[IMPORTANT]
63+
====
64+
_Do not edit these files directly_. Instead, use them as references when creating a custom skin. Start by reviewing:
6565
66-
The general workflow is that you look inside the less files within the theme folder and copy the variables you like to change into your skin's `skin.less` file.
66+
* `+modules/oxide/src/less/theme/globals/global-variables.less+`
67+
* `+modules/oxide/src/less/theme/components/toolbar-button/toolbar-button.less+`
6768
68-
NOTE: The skin *only* changes the visual presentation of the UI and *not* the placement of elements. Placement of elements is done by the {productname} UI framework. This framework makes it possible to do complex UI layouts on all browsers without touching any CSS when plugins are created.
69+
The typical workflow involves copying variables from the theme folder into the skins `skin.less` file and modifying them as needed.
70+
====
6971

70-
=== Creating a skin
72+
[NOTE]
73+
Skins **only** affect the visual appearance of the UI. Element positioning is managed by {productname}'s UI framework.
7174

72-
. Begin by duplicating the `default` folder located in `modules/oxide/src/less/skins/ui/` and rename it to the name of your skin.
73-
. Start the development server using the terminal command `yarn oxide-start`. If you already have the server running, you need to restart it to make it recognize your new skin using `ctrl-c` and then start it again.
74-
. Open the file `modules/oxide/src/less/skin/ui/<your-skin-name>/skin.less`.
75-
. Open any less file located in the theme folder, for example `modules/oxide/src/less/theme/globals/global-variables.less` and copy a variable you like to change, it's easiest to copy the whole line. Let's copy the `@background-color` variable to start with.
76-
. Paste the variable into the `skin.less` file you opened in step 2. For a striking look, change the variable value to be red, like this: `@background-color: red;`. Then save the file.
75+
[[creating-a-skin]]
76+
=== Creating a Skin
7777

78-
Your skin.less file should now look like this:
79-
80-
[source, less]
78+
. Duplicate the `+default+` folder in `+modules/oxide/src/less/skins/ui/+` and rename it.
79+
. Rebuild the project to recognize the newly created skins by running:
80+
+
81+
[source,sh]
8182
----
82-
/**
83-
* Copyright (c) Tiny Technologies, Inc. All rights reserved.
84-
* Licensed under the LGPL or a commercial license.
85-
* For LGPL see License.txt in the project root for license information.
86-
* For commercial licenses see https://www.tiny.cloud/
87-
*/
83+
yarn build
84+
----
85+
. Start the development server by running:
86+
+
87+
[source,sh]
88+
----
89+
yarn oxide-start
90+
----
91+
+
92+
[TIP]
93+
If the server is already running, restart it (`+Ctrl+C+`) and run the command again.
8894

95+
. Open `+modules/oxide/src/less/skin/ui/<your-skin-name>/skin.less+`.
96+
. Open a Less file from the theme folder (e.g., `+modules/oxide/src/less/theme/globals/global-variables.less+`) and copy a variable to modify. For example:
97+
+
98+
[source,less]
99+
----
100+
@background-color: red;
101+
----
102+
. Paste the variable into the `skin.less` file.
103+
+
104+
The updated `skin.less` should look like this:
105+
+
106+
[source,less]
107+
----
89108
@import 'src/less/theme/theme';
90109
91110
//
@@ -94,29 +113,60 @@ Your skin.less file should now look like this:
94113
95114
@background-color: red;
96115
----
97-
Switch to the web browser. Select your skin from the _Skin menu_. It should show a fiery red editor
116+
+
117+
. Save the file and check the changes in a browser. Select the skin from the _Skin menu_.
118+
. The editor should now display with a red background.
119+
120+
image::SDK-for-silver-custom-example.png[{productname} Skin SDK for the Silver theme]
121+
122+
This method allows customization of {productname} by modifying predefined variables, such as toolbar spacing or letter spacing.
98123

99-
image::SDKforsilverCustomExample.png[{productname} skin SDK for Silver theme]
124+
[TIP]
125+
Adjust {productname} configurations in `+modules/oxide/src/demo/index.html+` to match specific use cases.
100126

101-
This is how you skin {productname}: copy variables from the files in the theme folder and paste them into your skin file. There are variables for most things, like spacing between toolbar buttons to letter spacing. Simple yet powerful.
127+
== Creating a Content CSS File
102128

103-
TIP: You can change the {productname} config in `modules/oxide/src/demo/index.html` to suit your particular use case.
129+
To modify the appearance of content inside the editor (e.g., headings, lists, quotes), create a content CSS file:
104130

105-
== Creating a content CSS file
131+
. Create a folder in `+modules/oxide/src/less/skins/content/+` and add a `content.less` file. Alternatively, duplicate an existing content CSS file.
132+
. Rebuild the project to recognize the newly created content skin.
133+
+
134+
[source,sh]
135+
----
136+
yarn build
137+
----
138+
. Start the development server:
139+
+
140+
[source,sh]
141+
----
142+
yarn oxide-start
143+
----
144+
+
145+
[TIP]
146+
If the server is already running, restart it (`+Ctrl+C+`) and run the command again.
106147

107-
To update the appearance of the content within the editor, such as headings, quotes, lists, etc... you create a content css. These are located in `modules/oxide/src/less/skin/content/`
148+
. Add styles for relevant elements (`h1` to `h6`, `a`, `blockquote`, `code`, `table`, etc.). For example:
149+
+
150+
[source,less]
151+
----
152+
h1 {
153+
color: red;
154+
}
155+
----
156+
+
157+
. Save the file and check the changes in a browser.
158+
. The editor should now display with red headings.
108159

109-
. Create a folder in `modules/oxide/src/less/skins/content/` and create a `content.less` file in it. Alternatively, you can duplicate any of the existing content css.
110-
. Start the development server using the terminal command yarn oxide-start. If you already have the server running, you need to restart it to make it recognize your new skin using ctrl-c and then start it again.
111-
. Add the relevant element selectors for the desired use case such as `h1` to `h6`, `a`, `blockquote`, `code`, `table`, etc...
160+
== Moving the Skin into {productname}
112161

113-
== Moving the skin into TinyMCE
162+
. Copy the skin and/or content CSS from `+modules/oxide/build/skins/+` to the appropriate folders in the production {productname} setup.
163+
. Update {productname}'s initialization options:
114164

115-
. Copy the skin and/or content CSS from `modules/oxide/build/skins/` to the corresponding folders in your production {productname} folder.
116-
. Update the {productname} init function with the xref:editor-appearance.adoc#skin[skin] option and/or the xref:content-appearance.adoc#content_css[content_css] option.
165+
* Use the xref:editor-skin.adoc#skin[skin] option for UI skins.
166+
* Use the xref:add-css-options.adoc#content_css[content_css] option for content styles.
117167

118-
For more information on how to specify the location of the skin file, see xref:editor-appearance.adoc#skin_url[this] section.
168+
For details on specifying the skin file location, see xref:editor-skin.adoc#skin_url[this section].
119169

120-
== Modifying the icons
170+
== Modifying Icons
121171

122-
For information on adding custom icons, see: xref:creating-an-icon-pack.adoc[Create an icon pack for {productname}].
172+
For details on adding custom icons, see: xref:creating-an-icon-pack.adoc[Create an Icon Pack for {productname}].

0 commit comments

Comments
 (0)