Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

codelabs-react

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

codelabs-react - npm Package Compare versions

Comparing version 3.1.0 to 3.2.0

dist/components/onpagenavigation.js

43

dist/components.js

@@ -33,2 +33,8 @@ "use strict";

});
Object.defineProperty(exports, "OnPageNavigation", {
enumerable: true,
get: function get() {
return _onpagenavigation.OnPageNavigation;
}
});

@@ -39,2 +45,4 @@ var _react = _interopRequireDefault(require("react"));

var _onpagenavigation = require("./components/onpagenavigation");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

@@ -101,24 +109,39 @@

function H2(_ref6) {
var children = _ref6.children;
return /*#__PURE__*/_react["default"].createElement("h2", null, children);
var id = _ref6.id,
children = _ref6.children;
return /*#__PURE__*/_react["default"].createElement("h2", {
id: id
}, children);
}
function H3(_ref7) {
var children = _ref7.children;
return /*#__PURE__*/_react["default"].createElement("h3", null, children);
var id = _ref7.id,
children = _ref7.children;
return /*#__PURE__*/_react["default"].createElement("h3", {
id: id
}, children);
}
function H4(_ref8) {
var children = _ref8.children;
return /*#__PURE__*/_react["default"].createElement("h4", null, children);
var id = _ref8.id,
children = _ref8.children;
return /*#__PURE__*/_react["default"].createElement("h4", {
id: id
}, children);
}
function H5(_ref9) {
var children = _ref9.children;
return /*#__PURE__*/_react["default"].createElement("h5", null, children);
var id = _ref9.id,
children = _ref9.children;
return /*#__PURE__*/_react["default"].createElement("h5", {
id: id
}, children);
}
function H6(_ref10) {
var children = _ref10.children;
return /*#__PURE__*/_react["default"].createElement("h6", null, children);
var id = _ref10.id,
children = _ref10.children;
return /*#__PURE__*/_react["default"].createElement("h6", {
id: id
}, children);
}

@@ -125,0 +148,0 @@

@@ -120,2 +120,22 @@ "use strict";

}, _callee4);
})));
test("In page navigation is present", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5() {
return regeneratorRuntime.wrap(function _callee5$(_context5) {
while (1) {
switch (_context5.prev = _context5.next) {
case 0:
(0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Codelabs.Default, null));
_react2.fireEvent.click(_react2.screen.getByText("Getting set up"));
expect(_react2.screen.getByRole("link", {
name: "Get a key for the Dark Sky API"
})).toBeInTheDocument();
case 3:
case "end":
return _context5.stop();
}
}
}, _callee5);
})));

@@ -28,2 +28,3 @@ "use strict";

};
var idCount = 0;

@@ -176,5 +177,7 @@ function parse(response, iframeSourceUrls) {

try {
return {
var header = {
type: mapping[paragraph.paragraphStyle.namedStyleType]
};
header.id = "".concat(header.type, "-").concat(idCount++);
return header;
} catch (e) {

@@ -249,3 +252,6 @@ // defaults to p

return headingNodes.map(getParagraphText).map(function (header) {
return header.trim();
return {
id: "h1-".concat(idCount++),
content: header.trim()
};
});

@@ -252,0 +258,0 @@ }

@@ -21,2 +21,8 @@ "use strict";

});
Object.defineProperty(exports, "OnPageNavigation", {
enumerable: true,
get: function get() {
return _components.OnPageNavigation;
}
});
Object.defineProperty(exports, "Content", {

@@ -149,2 +155,4 @@ enumerable: true,

var _pagenavigations = _interopRequireDefault(require("./pagenavigations"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

@@ -191,2 +199,3 @@

var SideNavigationComponent = overrides.SideNavigation || _components.SideNavigation;
var OnPageNavigationComponent = overrides.OnPageNavigation || _components.OnPageNavigation;
var ContentComponent = overrides.Content || _components.Content;

@@ -219,15 +228,15 @@ var MainComponent = overrides.Main || _components.Main;

h2: function h2(props) {
return /*#__PURE__*/_react["default"].createElement(H2Component, null, props.children);
return /*#__PURE__*/_react["default"].createElement(H2Component, props, props.children);
},
h3: function h3(props) {
return /*#__PURE__*/_react["default"].createElement(H3Component, null, props.children);
return /*#__PURE__*/_react["default"].createElement(H3Component, props, props.children);
},
h4: function h4(props) {
return /*#__PURE__*/_react["default"].createElement(H4Component, null, props.children);
return /*#__PURE__*/_react["default"].createElement(H4Component, props, props.children);
},
h5: function h5(props) {
return /*#__PURE__*/_react["default"].createElement(H5Component, null, props.children);
return /*#__PURE__*/_react["default"].createElement(H5Component, props, props.children);
},
h6: function h6(props) {
return /*#__PURE__*/_react["default"].createElement(H6Component, null, props.children);
return /*#__PURE__*/_react["default"].createElement(H6Component, props, props.children);
},

@@ -272,6 +281,10 @@ li: function li(props) {

});
var pageNavigations = (0, _pagenavigations["default"])(parsedContent.pages, parsedContent.headings);
return /*#__PURE__*/_react["default"].createElement(PageComponent, {
title: parsedContent.title,
navigationItems: parsedContent.headings,
navigationItems: parsedContent.headings.map(function (heading) {
return heading.content;
}),
pages: pages,
pageNavigations: pageNavigations,
currentPage: page,

@@ -283,2 +296,3 @@ setPage: setPage,

SideNavigationComponent: SideNavigationComponent,
OnPageNavigationComponent: OnPageNavigationComponent,
ContentComponent: ContentComponent,

@@ -360,4 +374,5 @@ MainComponent: MainComponent,

var title = _ref3.title,
pageNavigations = _ref3.pageNavigations,
pages = _ref3.pages,
navigationItems = _ref3.navigationItems,
pages = _ref3.pages,
currentPage = _ref3.currentPage,

@@ -369,2 +384,3 @@ setPage = _ref3.setPage,

SideNavigationComponent = _ref3$overrides.SideNavigationComponent,
OnPageNavigationComponent = _ref3$overrides.OnPageNavigationComponent,
ContentComponent = _ref3$overrides.ContentComponent,

@@ -405,3 +421,6 @@ MainComponent = _ref3$overrides.MainComponent,

}
}, "Next"))))));
}, "Next")))), /*#__PURE__*/_react["default"].createElement(OnPageNavigationComponent, {
currentPage: currentPage,
items: pageNavigations
})));
}
{
"name": "codelabs-react",
"version": "3.1.0",
"version": "3.2.0",
"description": "",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

import React from "react";
import { CopyToClipboard } from "./components/copytoclipboard";
import { OnPageNavigation } from "./components/onpagenavigation";

@@ -79,20 +80,20 @@ export function Header({ title }) {

export function H2({ children }) {
return <h2>{children}</h2>;
export function H2({ id, children }) {
return <h2 id={id}>{children}</h2>;
}
export function H3({ children }) {
return <h3>{children}</h3>;
export function H3({ id, children }) {
return <h3 id={id}>{children}</h3>;
}
export function H4({ children }) {
return <h4>{children}</h4>;
export function H4({ id, children }) {
return <h4 id={id}>{children}</h4>;
}
export function H5({ children }) {
return <h5>{children}</h5>;
export function H5({ id, children }) {
return <h5 id={id}>{children}</h5>;
}
export function H6({ children }) {
return <h6>{children}</h6>;
export function H6({ id, children }) {
return <h6 id={id}>{children}</h6>;
}

@@ -218,2 +219,2 @@

export { CopyToClipboard };
export { CopyToClipboard, OnPageNavigation };

@@ -80,1 +80,11 @@ import React from "react";

});
test("In page navigation is present", async () => {
render(<Default />);
fireEvent.click(screen.getByText("Getting set up"));
expect(
screen.getByRole("link", {
name: "Get a key for the Dark Sky API",
})
).toBeInTheDocument();
});

@@ -5,2 +5,3 @@ import url from "url";

const warningColor = { red: 0.9882353, green: 0.8980392, blue: 0.8039216 };
let idCount = 0;

@@ -199,5 +200,7 @@ function parse(response, iframeSourceUrls) {

try {
return {
const header = {
type: mapping[paragraph.paragraphStyle.namedStyleType],
};
header.id = `${header.type}-${idCount++}`;
return header;
} catch (e) {

@@ -258,3 +261,8 @@ // defaults to p

const headingNodes = extractHeadingNodes(content);
return headingNodes.map(getParagraphText).map((header) => header.trim());
return headingNodes.map(getParagraphText).map((header) => {
return {
id: `h1-${idCount++}`,
content: header.trim(),
};
});
}

@@ -261,0 +269,0 @@

@@ -6,2 +6,3 @@ import React, { useState } from "react";

SideNavigation,
OnPageNavigation,
Content,

@@ -30,2 +31,3 @@ Main,

import Extract from "./extract";
import parsePageNavigations from "./pagenavigations";

@@ -47,2 +49,4 @@ // TODO: this function is a mess, need to break it apart

const SideNavigationComponent = overrides.SideNavigation || SideNavigation;
const OnPageNavigationComponent =
overrides.OnPageNavigation || OnPageNavigation;
const ContentComponent = overrides.Content || Content;

@@ -75,7 +79,7 @@ const MainComponent = overrides.Main || Main;

p: (props) => <ParagraphComponent>{props.children}</ParagraphComponent>,
h2: (props) => <H2Component>{props.children}</H2Component>,
h3: (props) => <H3Component>{props.children}</H3Component>,
h4: (props) => <H4Component>{props.children}</H4Component>,
h5: (props) => <H5Component>{props.children}</H5Component>,
h6: (props) => <H6Component>{props.children}</H6Component>,
h2: (props) => <H2Component {...props}>{props.children}</H2Component>,
h3: (props) => <H3Component {...props}>{props.children}</H3Component>,
h4: (props) => <H4Component {...props}>{props.children}</H4Component>,
h5: (props) => <H5Component {...props}>{props.children}</H5Component>,
h6: (props) => <H6Component {...props}>{props.children}</H6Component>,
li: (props) => (

@@ -116,7 +120,13 @@ <ListItemComponent {...props}>{props.children}</ListItemComponent>

const pageNavigations = parsePageNavigations(
parsedContent.pages,
parsedContent.headings
);
return (
<PageComponent
title={parsedContent.title}
navigationItems={parsedContent.headings}
navigationItems={parsedContent.headings.map((heading) => heading.content)}
pages={pages}
pageNavigations={pageNavigations}
currentPage={page}

@@ -128,2 +138,3 @@ setPage={setPage}

SideNavigationComponent,
OnPageNavigationComponent,
ContentComponent,

@@ -209,4 +220,5 @@ MainComponent,

title,
pageNavigations,
pages,
navigationItems,
pages,
currentPage,

@@ -218,2 +230,3 @@ setPage,

SideNavigationComponent,
OnPageNavigationComponent,
ContentComponent,

@@ -269,2 +282,6 @@ MainComponent,

</ContentComponent>
<OnPageNavigationComponent
currentPage={currentPage}
items={pageNavigations}
/>
</MainComponent>

@@ -278,2 +295,3 @@ </div>

SideNavigation,
OnPageNavigation,
Content,

@@ -280,0 +298,0 @@ Main,

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc