Skip to content
master
Switch branches/tags
Code

Latest commit

 - @times-components/ad@2.13.11
 - @times-components/article-byline@3.5.30
 - @times-components/article-comments@0.11.9
 - @times-components/article-error@0.2.178
 - @times-components/article-extras@0.7.0
 - @times-components/article-flag@2.10.6
 - @times-components/article-image@7.5.31
 - @times-components/article-in-depth@3.27.0
 - @times-components/article-label@2.7.53
 - @times-components/article-lead-asset@1.6.32
 - @times-components/article-list@9.7.26
 - @times-components/article-magazine-comment@3.27.0
 - @times-components/article-magazine-standard@3.27.0
 - @times-components/article-main-comment@2.27.0
 - @times-components/article-main-standard@3.32.0
 - @times-components/article-paragraph@1.4.153
 - @times-components/article-skeleton@1.45.0
 - @times-components/article-summary@3.16.50
 - @times-components/article-topics@4.2.8
 - @times-components/article@7.7.0
 - @times-components/author-profile@6.3.26
 - @times-components/button@2.4.58
 - @times-components/caption@3.0.137
 - @times-components/card@6.4.31
 - @times-components/date-publication@0.21.55
 - @times-components/edition-slices@0.104.12
 - @times-components/error-view@2.3.54
 - @times-components/gradient@3.2.54
 - @times-components/icons@2.14.55
 - @times-components/image@6.7.31
 - @times-components/interactive-wrapper@0.8.8
 - @times-components/key-facts@2.1.41
 - @times-components/lazy-load@0.6.19
 - @times-components/link@3.6.38
 - @times-components/markup@3.4.54
 - @times-components/message-bar@0.3.58
 - @times-components/pages@2.3.2
 - @times-components/pagination@3.4.44
 - @times-components/provider@1.24.9
 - @times-components/pull-quote@3.6.38
 - @times-components/related-articles@6.6.3
 - @times-components/responsive-image@0.6.17
 - @times-components/responsive@0.6.21
 - @times-components/save-and-share-bar@0.9.58
 - @times-components/save-star-web@0.6.55
 - @times-components/section@1.6.78
 - @times-components/slice-layout@0.47.10
 - @times-components/ssr@2.24.0
 - @times-components/star-button@0.3.37
 - @times-components/sticky@0.2.54
 - @times-components/storybook@4.1.60
 - @times-components/styleguide@3.38.16
 - @times-components/topic@5.3.26
 - @times-components/tracking@2.7.7
 - @times-components/user-state@0.1.57
 - @times-components/utils@6.5.0
 - @times-components/video-label@2.4.56
 - @times-components/video@4.11.3
 - @times-components/watermark@2.7.48
ba9072f

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
lib
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

The Times Component Library

Coverage Status Build Status

Purpose

Home of The Times' react/react native components, using react-native-web to share across platforms

Dev Environment

We require MacOS with Node.js (for specific version please check package.json restrictions), yarn (latest)

Native development requires Xcode, JDK 8 and pip.

You can try without these requirements, but you'd be on your own.

Viewing Our Components

Go to http://components.thetimes.co.uk

Getting Started

  1. Install fontforge: brew install fontforge (See Fonts section)

  2. Run yarn install

  3. Components can be seen running in a storybook:

Schema

See utils package on how to update the schema

Debugging

The components in this project can be debugged through your browser's developer tools. These steps assume the use of Chrome DevTools.

To debug our web Storybook:

  1. yarn storybook
  2. navigate to http://localhost:9001
  3. open DevTools
  4. Click Sources
  5. In the Network tab under the leftmost pane, expand top => storybook-preview-iframe => webpack:// => . => packages

Any of these source files can be debugged directly.

Link times-components to the Render project

Follow these steps here

Debugging the tests

Tests are currently using jest to run so if you want to debug any test follow these steps:

  1. (FIND YOUR TEST COMMAND) jest --config="./packages/provider/__tests__/jest.config.js". Depending on what directory we start the tests from, the --config directory may differ. My currenct directory is at the repo root: times-components.

  2. See your test command from the package.json for the speciffic package you want to check out.

NOTE: If you don't have jest installed globally, you can use it locally from the node_modules/.bin/jest

  1. (START TESTS IN DEBUG MODE) We need to start the same command but through node while in debug mode like so: node --inspect-brk ./node_modules/.bin/jest --config="./packages/provider/__tests__/jest.config.js" --runInBand

NOTE: --runInBand is a jest flag that runs all tests serially in the current process. If we don't add this flag, only the node process that started jest will be debuggable .

  1. (ADD DEBUG STATEMENTS) Normaly we would add breakpoints, but when remote debugging that's not always possible, because the files we need to put the breakpoints on aren't loaded yet by jest. So in order to make the debugger stop where we want it to, we need to add debugger; statements instead of breakpoints in the code and re-transpile if necessary.

  2. (ATTACH TO WEB SOCKET) Once we've started the tests in debug mode, we need to attach to it:

  • (RECOMMENDED) use chrome remote debug for node:

    1. open chrome://inspect in chrome address bar
    2. Open dedicated DevTools for Node button
    3. If you've started the tests with the aforementioned command it should automatically connect, but if it doesn't go to the Connection tab of the pop-up window and add connection localhost:9229 or whatever your port is
    4. The debugger should stop on the first line because of the --inspect-brk flag and once you press the play button (resume execution) it should stop on your debugger; statement

    NOTE: once it stops you may see all of your code is bundled up in one line. There's an easy fix for that: at the bottom of the debug window near the Line: 1 Column: 1 labels you should see a {} button that will prettify your code and you will still be able to debug properly.

  • (Use VSCode) Config should look close to this:

...
    "configurations": [
      {
          "localRoot": "${workspaceFolder}/packages/provider", //change this depending on what test you're debugging
          "remoteRoot": "${workspaceFolder}/packages/provider", //change this depending on what test you're debugging
          "type": "node",
          "request": "attach",
          "name": "Attach to Server on 9229",
          "address": "127.0.0.1",
          "port": 9229
      }
  ]

Contributing

See the CONTRIBUTING.md for an extensive breakdown of the project

yarn commit will commit files (same as git commit), and will aid the contributor with adding a suitable commit message inline with conventional changelog